RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
I have a sub-routine that compares sheet A (mvNew) to sheet B, any row discrepancy increments a count and stores the row# in an array called vRows. That part is fine so I won't include that code. The trouble comes when the count is 1. Here's a code snippit where I'm having the problem. See code comments for line explanations.
So the Application.Index automatically converts vTraining_(1 to 1, 1 to 13) to vTraining_(1 to 13) and this mucks up further downstream methods. Any thoughts on what the best strategy is to get my 2D array back?
VBA Code:
If iCount > 0 Then
ReDim Preserve vRows(1 To iCount) 'This is an array of row #s that are recorded during the comparison algorithm
ReDim vTraining_(1 To UBound(vRows), 1 To 13) 'After this line executes my dimensions of vTraining_ are (1 to 1, 1 to 13) as UBound(vRows) = 1
vTraining_ = Application.Index(mvNew, Application.Transpose(vRows), vColumns) 'After this line executes my dimensions of vTraining_ are (1 to 13)
'How can I get this vTraining_ array back to (1 to 1, 1 to 13)???
'In order for the "FormDataArray" method to work, the vTraining_ array has to be a 2D array
Call FormDataArray
Call InsertNewRows
End If
So the Application.Index automatically converts vTraining_(1 to 1, 1 to 13) to vTraining_(1 to 13) and this mucks up further downstream methods. Any thoughts on what the best strategy is to get my 2D array back?