Hi..
Any idé how to use For Each with an array?
Example code please where I can se how to access the array within the For Each loop to..
Thanks!!
Printable View
Hi..
Any idé how to use For Each with an array?
Example code please where I can se how to access the array within the For Each loop to..
Thanks!!
Code:Private Sub Form_Load()
Dim sArray(1 To 10) As Integer
Dim sCurrent As Variant ' control variable for processing for each loop **MUST BE OF DATA TYPE VARIANT
'Fill array with random number between 0 and 300
For i = 1 To 10
sArray(i) = (Rnd * 300)
Next i
'Display array in Immediate Window
For Each sCurrent In sArray
Debug.Print sCurrent
Next sCurrent
End Sub
TNX!!!
Perfect =)