TheWennerWoman
Active Member
- Joined
- Aug 1, 2019
- Messages
- 303
- Office Version
- 365
- Platform
- Windows
Starting at row 1, I have 36 columns of data (AA thru BJ) which go down to row 1111 for a total of 39996 records. These are dice rolls which I need put into columns B and C (starting at row 2).
The logic is AA1 goes into B2, AB1 goes into C2, AC1 goes into B3, AD1 goes into C3. Once BJ1 has been processed this should have populated cells B2:B19 and C2:C19. We then move onto AA2 goes into B20, AB2 goes into C20 and so on.
I tried cannibalising something similar that someone kindly provided (below) but it falls over with "subscript out of range" (I think it's because that piece of code was dealing with only 1 column of data, not 36.
Any thought greatly appreciated.
The logic is AA1 goes into B2, AB1 goes into C2, AC1 goes into B3, AD1 goes into C3. Once BJ1 has been processed this should have populated cells B2:B19 and C2:C19. We then move onto AA2 goes into B20, AB2 goes into C20 and so on.
I tried cannibalising something similar that someone kindly provided (below) but it falls over with "subscript out of range" (I think it's because that piece of code was dealing with only 1 column of data, not 36.
Any thought greatly appreciated.
VBA Code:
Sub r_make_2_cols_from_array()
Dim Ary As Variant, Nary As Variant
Dim r As Long, nr As Long, nc As Long
Ary = Range("AA1:BJ1111").Value2
ReDim Nary(1 To 20000, 1 To 2)
For r = 1 To UBound(Ary) Step 2
nr = nr + 1
Nary(nr, 1) = Ary(r, 1)
Nary(nr, 2) = Ary(r + 1, 1)
Next r
Range("B2").Resize(20000, 2).Value = Nary
'If Application.WorksheetFunction.Sum(Range("B2:C49999")) <> Application.WorksheetFunction.Sum(Range("Z2:Z40001")) Then
' MsgBox "Something went wrong!"
'Else
' MsgBox "Done!"
End If
End Sub