I'm trying to create an array of cell entries (e.g. A6,B6, etc) that populates in a for loop.
However the array
MyArray
is always empty and I can't figure out why its not being populated within the for loop. Below is (the appropriate part of-the code is doing other stuff to) my code:
Sub ListSheets()
' Defining all variables (objects) used within the code, establishing their
'classes
Dim i As Integer
Dim array_size As Integer
Dim MyArray() As String
array_size = 26
ReDim MyArray(array_size) As String
For intLoop = 1 To 26
MyArray(intLoop, 1) = Chr$(64 + intLoop) + "6"
Next
Set CopyFrom = MyArray
Sheets("vba_deposit").Range("A1").Resize(CopyFrom.Rows.Count).Value = CopyFrom.Value
End Sub
Any ideas?
Many thanks in advance.
MyArray(intLoop, 1) = ...->MyArray(intLoop) = ...MyArray(intLoop, 1)but withReDim MyArray(1 To array_size, 1 To 1). See my answer belowMyArray(intLoop, 1)or making it a 2-D array. You simply need to start your loop from 0 rather than 1.