Hi,
I am stuck. I am trying to copy some selected rows from one column of a 2-D array to a particular column of another 2-D Array. I have tried all my knowledge, but to no avail.
You can see that I can do that while writing to an excel range in
I can also do that when I output it to the first column using
But as soon as I am trying to put the result in column 2 of out array here,
Any help is highly appreciated.
FYI, my sample input, if anyone is interested.
I am stuck. I am trying to copy some selected rows from one column of a 2-D array to a particular column of another 2-D Array. I have tried all my knowledge, but to no avail.
VBA Code:
Sub TestIndxPst()
Dim varArray As Variant
ReDim varArray(1 To 4, 1 To 3)
Dim vaOut As Variant
ReDim vaOut(1 To 4, 1 To 3)
RowNumArray = Evaluate("transpose(Row(1" & ":" & 5 & "))")
varArray = ThisWorkbook.Worksheets("Sheet1").Range("G2:I7")
Application.Index([G9:I12], , 2) = Application.Transpose(Application.Index(varArray, Array(2, 3, 5, 6), 2))
vaOut = Application.Transpose(Application.Index(varArray, Array(2, 3, 5, 6), 2))
Application.Index(vaOut, , 2) = Application.Transpose(Application.Index(varArray, Array(2, 3, 5, 6), 2))
For i = LBound(vaOut) To UBound(vaOut)
Debug.Print vaOut(i, 1)
Next i
End Sub
You can see that I can do that while writing to an excel range in
Application.Index([G9:I12], , 2) = Application.Transpose(Application.Index(varArray, Array(2, 3, 5, 6), 2))
I can also do that when I output it to the first column using
vaOut = Application.Transpose(Application.Index(varArray, Array(2, 3, 5, 6), 2))
But as soon as I am trying to put the result in column 2 of out array here,
Application.Index(vaOut, , 2) = Application.Transpose(Application.Index(varArray, Array(2, 3, 5, 6), 2))
. I get application-defined or object defined errorAny help is highly appreciated.
FYI, my sample input, if anyone is interested.