PDA

View Full Version : Solved: Shifting rows to the right.



twelvety
03-09-2009, 08:10 AM
Hi experts,

I want to shift the first 11 rows in my spreadsheet 16 columns to the right, the next 11 rows 15 columns to the right, the next 11 rows 14 across, etc etc

This will happen for the first 176 rows (i.e. until the last block of 11 is moved only 1 to the right)

If anyone can supply code to do this it would be really appreciated.

Thanks in advance

Chris

Bob Phillips
03-09-2009, 08:35 AM
Dim i As Long
Dim LastRow As Long
Dim ShiftRows As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
ShiftRows = 16
For i = 1 To LastRow Step 11

.Cells(i, "A").Resize(11, ShiftRows).Insert Shift:=xlToRight
ShiftRows = ShiftRows - 1
If ShiftRows < 1 Then ShiftRows = 1
Next i
End With