Some example methods here ...
Public Sub DefineArray()
Dim i As Long
' ---------------------------------------------------------------
' Using the Array function
' ---------------------------------------------------------------
Dim arrTest1 As Variant
arrTest1 = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
For i = 0 To UBound(arrTest1)
Debug.Print arrTest1(i)
Next
' ---------------------------------------------------------------
' ReDim Preserve
' ---------------------------------------------------------------
Dim arrTest2() As String
For i = 0 To 10
ReDim Preserve arrTest2(i)
arrTest2(i) = i
Next
For i = 0 To UBound(arrTest2)
Debug.Print arrTest2(i)
Next
' ---------------------------------------------------------------
' Fixed at declaration
' ---------------------------------------------------------------
Dim arrTest3(10) As String
For i = 0 To UBound(arrTest3)
arrTest3(i) = i
Next
For i = 0 To UBound(arrTest3)
Debug.Print arrTest3(i)
Next
' ---------------------------------------------------------------
' Using a function that returns an array, e.g. Split
' ---------------------------------------------------------------
Dim strTest As String, arrTest4 As Variant
strTest = "This is a test"
arrTest4 = Split(strTest, " ")
For i = 0 To UBound(arrTest4)
Debug.Print arrTest4(i)
Next
' ---------------------------------------------------------------
' From a range
' ---------------------------------------------------------------
Dim arrTest5 As Variant, lngRow As Long, lngCol As Long
arrTest5 = Sheet1.Range("A1:K10").Value
For lngRow = LBound(arrTest5, 1) To UBound(arrTest5, 1)
For lngCol = LBound(arrTest5, 2) To UBound(arrTest5, 2)
Debug.Print arrTest5(lngRow, lngCol)
Next
Next
End Sub
Hopefully that gives you a good cross section and as per the comment, make sure it's contained within a function or procedure (sub). See my example.