ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   array inside for statement (https://www.excelbanter.com/excel-programming/404105-array-inside-statement.html)

Student

array inside for statement
 
Hello
i have an array inside a for statment and i was to reset the array everytime
the for statment run
how may i rest an array
please advice thank you

Jim Thomlinson

array inside for statement
 
So you want to resize the array each time you loop? If so then take a look at
ReDim Preserve. Something like this...

Sub Tada()
Dim MyArray() As Long
Dim lng As Long

For lng = 0 To 9
ReDim Preserve MyArray(lng)
MyArray(lng) = lng
Next lng

For lng = LBound(MyArray) To UBound(MyArray)
MsgBox MyArray(lng)
Next lng
End Sub
--
HTH...

Jim Thomlinson


"Student" wrote:

Hello
i have an array inside a for statment and i was to reset the array everytime
the for statment run
how may i rest an array
please advice thank you



All times are GMT +1. The time now is 03:14 PM.

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