I know I can quickly fill a worksheet with an array referencing a value using something like this:
Dim thisArray(6 To 139, 6 To 40) As Variant
Dim x As String
dim row, col As Integer
for row from 6 to 139 step 1
for col from 6 to 40 step 1
thisArray(row, col) = row * col
next col
next row
x = "F6:AN139"
ActiveWorkbook.Sheets(1).Range(x) = thisArray
however, if "thisArray" references a one-dimensional array with two elements,
thisArray(6, 6) = Array(amt, errCode)
this type of assignment won't work. I'd like to select the first element in the referenced array to fill the range. I tried this but the compiler complained about the wrong number of dimensions.
Activeworkbook.Sheets(1).Range(x) = thisArray(0)
I've got it to work by going cell by cell and making the correct assignment, but it's slow compared to the direct assignment method referenced in the first example.
Dim thisArray(6 To 139, 6 To 40) As Variant
Dim x As String
dim row, col As Integer
for row from 6 to 139 step 1
for col from 6 to 40 step 1
thisArray(row, col) = row * col
next col
next row
x = "F6:AN139"
ActiveWorkbook.Sheets(1).Range(x) = thisArray
however, if "thisArray" references a one-dimensional array with two elements,
thisArray(6, 6) = Array(amt, errCode)
this type of assignment won't work. I'd like to select the first element in the referenced array to fill the range. I tried this but the compiler complained about the wrong number of dimensions.
Activeworkbook.Sheets(1).Range(x) = thisArray(0)
I've got it to work by going cell by cell and making the correct assignment, but it's slow compared to the direct assignment method referenced in the first example.
Last edited: