Rearrange Table Data

Carin

Board Regular
Joined
Feb 4, 2006
Messages
224
I have 14 tables merged into one large table which I would like to move into one column.
Table 1 = B1:M5
Table 2 = B6:M10
Table 3 = B11:M15
etc.
I would like a code to move
B1:B5 => A1:A5
C1:C5 => A6:A11
D1:D5 => A12:A17
etc., ending at A60 - then wrap down to
B6:B10 => A61:A65
just continue moving five rows of data from B to M and once that data has been moved, move down and grab the next five rows of data.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this - it copies rather than moves so you can check if it works. If it does, it can be amended to move.

Code:
Sub atest()
Dim i As Integer, j As Integer, k As Integer
k = 1
For i = 1 To 11 Step 5
    For j = 2 To 13
        Cells(i, j).Resize(5).Copy Destination:=Cells(k, 1)
        k = k + 5
    Next j
Next i
End Sub
 
Upvote 0
Excellent! This modification will move rather than copy:

Rich (BB code):
Sub atest()
Dim i As Integer, j As Integer, k As Integer
k = 1
For i = 1 To 11 Step 5
    For j = 2 To 13
        Cells(i, j).Resize(5).Cut Destination:=Cells(k, 1)
        k = k + 5
    Next j
Next i
End Sub
 
Upvote 0
Thanks so much...this works for three of my groups...how do I get it to work for all 14 groups?
 
Upvote 0
Assuming that the complete range is B1:M70 try

Code:
Sub atest()
Dim i As Integer, j As Integer, k As Integer
k = 1
For i = 1 To 66 Step 5
    For j = 2 To 13
        Cells(i, j).Resize(5).Cut Destination:=Cells(k, 1)
        k = k + 5
    Next j
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top