ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filling an array with a Loop (https://www.excelbanter.com/excel-programming/349406-filling-array-loop.html)

Kevin O'Neill[_2_]

Filling an array with a Loop
 
Dim d as String
For d = 0 to 6
ends(d) = Range("A50000").End(xlUp).Row
Next d

I want to populate the array with the end row of each of my loops, and
then pass that array to another sub for use.

Suggestions?


Kevin O'Neill[_2_]

Filling an array with a Loop
 
Dim ends(5) As Integer
For d = 5 to 0 step -1
ends(d) = Range("A50000").End(xlUp).Row
Next d

Better. It works, but, my array size will not always be 5 (6 including
0). It must be constant? My loop steps backwards, and fills my array
backwards. How can I reverse it?


voodooJoe

Filling an array with a Loop
 
kevin -

i find this a little puzzling.

is ends(5) supposed to be the same number as ends(0)? in this example you
always start with the same cell (A50000) and go up - with nothing else in
the loop all ends(x) will be the same

have you tried offset? like:

ends = range("a100").offset(5,0)

ends then becomes an array of values

- voodooJoe

"Kevin O'Neill" wrote in message
oups.com...
Dim ends(5) As Integer
For d = 5 to 0 step -1
ends(d) = Range("A50000").End(xlUp).Row
Next d

Better. It works, but, my array size will not always be 5 (6 including
0). It must be constant? My loop steps backwards, and fills my array
backwards. How can I reverse it?




Kevin O'Neill[_2_]

Filling an array with a Loop
 
Joe, there is actually alot of other code inside the loop I cut out, I
just didn't show it. I managed to figure it out. Thanks.



All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com