I have 3 variant arrays: Array1 Array2 Array3
I am wanting to add the counter value of my for loop to the end of the array name to save repeating the same code line over e.g. :
For i = 1 To oXlWkBk.Sheets.Count
FillArray ArraySource & i, "B1:" & oCurrentWs.Cells(lNumRows, lNumCols).Address(RowAbsolute:=False, ColumnAbsolute:=False)
Next i
instead of:
For i = 1 To oXlWkBk.Sheets.Count
FillArray ArraySource1, "B1:" & oCurrentWs.Cells(lNumRows, lNumCols).Address(RowAbsolute:=False, ColumnAbsolute:=False)
FillArray ArraySource2, "B1:" & oCurrentWs.Cells(lNumRows, lNumCols).Address(RowAbsolute:=False, ColumnAbsolute:=False)
FillArray ArraySource3, "B1:" & oCurrentWs.Cells(lNumRows, lNumCols).Address(RowAbsolute:=False, ColumnAbsolute:=False)
Next i
I've tried using:
- Array & i
- Array & Cstr(i)
- Array(i)
Is it possible to append the counter value as a suffix to complete the array name?
Scripting.Dictionaryinstead. Then you can use string keys.