Link to home
Start Free TrialLog in
Avatar of Saqib Husain
Saqib HusainFlag for Pakistan

asked on

Reducing an array

I have an array of data read off a worksheet using the statement

maxrds = dta.Range("a" & xls.Application.Rows.Count).End(xlUp).Row - datstart + 1

All variables are variants.

How can I create a similar array which has only even numbers in the first column?

Saqib
Avatar of Dave
Dave
Flag of Australia image

Saqib,

I think you will need to create a second array reading in every second record from your initial array (faster than writing every second cell to a single array)

Cheers

Dave
Avatar of Saqib Husain

ASKER

Hi, Dave,

I have not declared the size of the original array. It sizes it based on the assignment statement above. I would like to know a way to assign this to the new array without defining the length. So the main list might have 100 entries and the new list might have 70

The numbers would have to be checked for evenness, they are not regularly incrementing.
Sorry I had given the wrong assignment statement in the question. That was for calculation the number of entries in the range. The range assignment is given here

rds = WorksheetFunction.Transpose(dta.Range(dta.Cells(datstart, 1), dta.Cells(maxrds + datstart - 1, 1)).Value)

Can you pls post a sample Saqib
Dave,

I have created this file with the given numbers in column A.

In column D I have shown what values I would like to see in the reduced array. This column is not normally present.

I have also created a macro which assigns column A values to rds and column D values to rds2.

I would like to have rds contain the contents of rds2 instead of having a new variable rds2.

Saqib
Reducearray.xls
ASKER CERTIFIED SOLUTION
Avatar of Dave
Dave
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial