Ricardo4545
New Member
- Joined
- Apr 7, 2015
- Messages
- 3
Hello all, I just got introduced to VBA and am trying my first steps in it.
I have data in 3 consecutive rows (let's say A1:E3) and every 3 rows of data, I want to move that "block" --> two cells to the right.
So basically, I have:
That want to turn into
Thing is, I need to start o the active cell and not specifically A1 pushing it specifically to A3.
I'm using this code:
But i get the error: "runtime error 1004 method of worksheet class". Everything works just fine until the last "block" of data (E1:E3).
The line "ActiveSheet.Paste". Gets highlighted.
This may sound like an ultra naïve question, but I can't solve it.
Thanks in advance!
I have data in 3 consecutive rows (let's say A1:E3) and every 3 rows of data, I want to move that "block" --> two cells to the right.
So basically, I have:
Code:
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
That want to turn into
Code:
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
Thing is, I need to start o the active cell and not specifically A1 pushing it specifically to A3.
I'm using this code:
Code:
Sub Macro1()
Do Until IsEmpty(ActiveCell.Offset(0, 1))
ActiveCell.Offset(0, 1).Select
ActiveCell.Resize(3, 1).Select
Range(Selection, Selection.End(xlToRight)).Cut
ActiveCell.Offset(0, 2).Select
ActiveSheet.Paste
Loop
End Sub
But i get the error: "runtime error 1004 method of worksheet class". Everything works just fine until the last "block" of data (E1:E3).
The line "ActiveSheet.Paste". Gets highlighted.
This may sound like an ultra naïve question, but I can't solve it.
Thanks in advance!