Macro to transpose groups of data from rows to columns

megfitz

New Member
Joined
Jun 15, 2011
Messages
1
Hello all,

Thanks in advance for any help, I'm really stuck on this one! I have an excel worksheet with data in one row:

The Comfort Hotel
Hotels (Shops & other Retail Outlets) serving London area
3 Leisure Way, London, N12 0QZ
Tel: 020 84466644

Regent Lodge Hotel
Hotels (Shops & other Retail Outlets) serving London area
120 Regents Park Road, London, N3 3HY
Tel: 020 83464439

Holiday In Brent cross
Hotels (Shops & other Retail Outlets) serving London area
Tilling Road, London, NW2 1LP
Tel: 0870-400 9112

The Garth
Hotels (Shops & other Retail Outlets) serving London area
64-76 Hendon Way, London, NW2 2NL
Tel: 020 82091511

But I would like this data to appear as:
The Comfort Hotel Hotels (Shops & other Retail Outlets) serving London area 3 Leisure Way, London, N12 0QZ Tel: 020 84466644
Regent Lodge Hotel Hotels (Shops & other Retail Outlets) serving London area 120 Regents Park Road, London, N3 3HY Tel: 020 83464439
Holiday In Brent cross Hotels (Shops & other Retail Outlets) serving London area Tilling Road, London, NW2 1LP Tel: 0870-400 9112

So the first row of each group of four rows stays in column 1, the second row goes into column 2, the third in column 3, the fourth in column 4 and then after the line break it starts over.

Does anyone have any suggestions?

Thank you so much!
Meg
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
If your data starts on row 1 in column 1 of sheet1, this should work

It writes the data to a sheet called sheet2, but you can easily change the sheet names if you need to. Just make sure you have a free sheet to paste the data to. The original source data is not affected.

HTH

Code:
 Sub trans4x()
    Set src = Sheets("sheet1") 'source data
    Set dst = Sheets("sheet2") 'dstination
    lr = src.Cells(Rows.Count, 1).End(xlUp).Row
    fr = 1 'first row of source data
    pr = 1 'first row of destination
    For i = fr To lr Step 5
        src.Cells(i, 1).Resize(4).Copy
        dst.Cells(pr, 1).PasteSpecial Paste:=xlPasteAll, Transpose:=True
        pr = pr + 1
    Next
    dst.Range("A1:D1").EntireColumn.AutoFit 'resizes cols in destination sheet
End Sub
 
Upvote 0
Try This , Results start "H1".
If correct after you've run code Delete unwanted columns
Code:
Dim Rng As Range, Dn As Range
Set Rng = Columns("A:A").SpecialCells(xlCellTypeConstants)
    For Each Dn In Rng.Areas
        Range("H" & rows.Count).End(xlUp).Offset(1).Resize(, Dn.Count) = _
        Application.Transpose(Dn)
    Next Dn
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,240
Members
452,898
Latest member
Capolavoro009

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