Sub TestForLoopVariableName()
Dim LCV1 As Integer, LCV2 As Integer, Counter as Integer
For LCV1= 1 To 10
For LCV2 = 1 To 10 'for control variable already in use
counter =counter + 1
Next LCV2
Next LCV1
End Sub
Use of proper parentheses declares an array variable
Create a one dimension Array with 10 "Slots" numbered 0 to 9, where each "slot" can only hold an integer.
Dim LCV(0 to 9) as integer
Create a one dimension Array with 10 "Slots" numbered 0 to 9, where each "slot" can only hold a String.
Dim LCV(0 to 9) as String
General Practice is to create Arrays that can hold any Type:
Create a Variant Variable that can hold darn near anything, and can be turned into an array
Turn a Variant into a 2D array 10 "Rows" deep and 10 "Columns" wide
Redim LCV(1 to 10, 2 to 11)
Create a filled Array from a Variant Variable
LCV = Array(1,"Abc",42,"DEf",2,3,4,5,6,"X")
Using a loop to fill a 1D array
Dim i as Long
Dim LCV(1 to 10) as Integer
For i = 1 to 10
LCV(i) = i 'VBA Converts Long i to an integer to fit the array "Slot". The Index i is a long.
Next i
Using loops to fill a 2D array
Dim i as Long, j As Long
Dim LCV
Redim LCV (1 To 10, 7 To 20)
For i = 1 To 10
For j = 7 To 20
LCV(i, j) = i x j
Next j
Next i
'Show the result on sheet1
Sheets("Sheet1").Range("A1").Resize(10, 14) = LCV.Value
Also see: http://www.snb-vba.eu/VBA_Arrays_en.html