array inside for statement

  • Thread starter Thread starter Student
  • Start date Start date
S

Student

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top