jollyreaper
New Member
- Joined
- Mar 10, 2019
- Messages
- 1
I'm new to VBA so I'm probably mucking up the syntax here. So here's what the data looks like.
There's chunks of information running down column C. They come in 92 line chunks and so I know the header name that defines the chunk will be in c2, c2+92, c2+92+92, etc. I just need to copy paste special values one cell down and to the right. For the first chunk, it's copy C2, move down and to the left to B3, paste special values, then repeat on down the sheet.
This is the code I wrote to do it and I think the basic logic of what I'm trying to do makes sense but I'm making a hash of the actual code.
I'm trying to setup a loop so that I can specify the active cell with variables and then iterate down through the data.
Where, oh where am I going wrong?
Thanks!
'Set cell to B3 to start script -- it will then move up and right to copy and down and left to paste
Range("B3").Select
'Set variable we're using to move down the cells b is for column b, c for column c
Dim a, b As Integer
c = 2
b = 3
'Iterate through this 65k times until we're past the 64k at the bottom
Do While c < 65000
'Setting for the game name in C, aka bartop, moving up to the right to copy
ActiveCell.Offset(c, 1).Range("C2").Select
Selection.Copy
'Move down to the left and copy
ActiveCell.Offset(b, -1).Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Incriment counters and loop back to beginning
c = c + 92
b = b + 92
Loop
End Sub
There's chunks of information running down column C. They come in 92 line chunks and so I know the header name that defines the chunk will be in c2, c2+92, c2+92+92, etc. I just need to copy paste special values one cell down and to the right. For the first chunk, it's copy C2, move down and to the left to B3, paste special values, then repeat on down the sheet.
This is the code I wrote to do it and I think the basic logic of what I'm trying to do makes sense but I'm making a hash of the actual code.
I'm trying to setup a loop so that I can specify the active cell with variables and then iterate down through the data.
Where, oh where am I going wrong?
Thanks!
'Set cell to B3 to start script -- it will then move up and right to copy and down and left to paste
Range("B3").Select
'Set variable we're using to move down the cells b is for column b, c for column c
Dim a, b As Integer
c = 2
b = 3
'Iterate through this 65k times until we're past the 64k at the bottom
Do While c < 65000
'Setting for the game name in C, aka bartop, moving up to the right to copy
ActiveCell.Offset(c, 1).Range("C2").Select
Selection.Copy
'Move down to the left and copy
ActiveCell.Offset(b, -1).Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Incriment counters and loop back to beginning
c = c + 92
b = b + 92
Loop
End Sub