List/Paste/Transpose?

cchrisj

New Member
Joined
Apr 6, 2003
Messages
5
I have a very long list (column) of records. It takes up only Column A. I need to transpose each record so each is in row (across 5 columns). Each record is the same number of cells (5) and the value of the last entry of each record is the same ("map"). Is there a formula/macro that will allow me to easily transpose each record from the column to a row?

THANKS for the consideration!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
if the data is cyclic you could make a macro kind of like this: keep in mind this is very simple, and will only work if the data you want to transpose follows the exact cycle throughout your spreadsheet. Make a command button somewhere near 0the top of your spread sheet, add this code (you can change the range("A1") to which column you have the data in).

Remember to test code on a copy of your spreadsheet before employing it in your valuable data.

Code:
Private Sub CommandButton1_Click()
Range("A1").Select
Do While ActiveCell <> ""
    ActiveCell.Offset(0, 1) = ActiveCell.Offset(1, 0)
    ActiveCell.Offset(0, 2) = ActiveCell.Offset(2, 0)
    ActiveCell.Offset(0, 3) = ActiveCell.Offset(3, 0)
    ActiveCell.Offset(0, 4) = ActiveCell.Offset(4, 0)
    
    ActiveCell.Offset(1, 0).ClearContents
    ActiveCell.Offset(2, 0).ClearContents
    ActiveCell.Offset(3, 0).ClearContents
    ActiveCell.Offset(4, 0).ClearContents
    
    ActiveCell.Offset(1, 0).Select
    Do Until ActiveCell <> ""
        Selection.EntireRow.Delete
    Loop
Loop
End Sub
 
Upvote 0
scratch that... that would have put you in an infinite loop, Sorry.

this won't throw you in an infinite loop

Code:
Private Sub CommandButton1_Click()
Range("A1").Select
Do While ActiveCell <> ""
    ActiveCell.Offset(0, 1) = ActiveCell.Offset(1, 0)
    ActiveCell.Offset(0, 2) = ActiveCell.Offset(2, 0)
    ActiveCell.Offset(0, 3) = ActiveCell.Offset(3, 0)
    ActiveCell.Offset(0, 4) = ActiveCell.Offset(4, 0)
    
    ActiveCell.Offset(1, 0).ClearContents
    ActiveCell.Offset(2, 0).ClearContents
    ActiveCell.Offset(3, 0).ClearContents
    ActiveCell.Offset(4, 0).ClearContents
    
    ActiveCell.Offset(1, 0).Select
    
    Selection.EntireRow.Delete
    Selection.EntireRow.Delete
    Selection.EntireRow.Delete
    Selection.EntireRow.Delete
    
Loop

End Sub

sorry for the trouble, and I hope this helps,
Kelethaar
 
Upvote 0
Formula approach:

1. Set up D1:H1 as shown below manually.

2. Enter C2:C3 manually then select and copy down as far as you might need.

3. Stand-alone formula in C1 (adjust range if > 1,000 rows)

4. Enter formula in D2 (adjust range if > 1,000 rows)

5. Copy D2 formula across and down

Excel Workbook
ABCDEFGH
1List2512345
2Item 10Item 1Item 2Item 3Item 4Item 5
3Item 25Item 6Item 7Item 8Item 9Item 10
4Item 310Item 11Item 12Item 13Item 14Item 15
5Item 415Item 16Item 17Item 18Item 19Item 20
6Item 520Item 21Item 22Item 23Item 24Item 25
7Item 625
8Item 730
9Item 8
10Item 9
11Item 10
12Item 11
13Item 12
14Item 13
15Item 14
16Item 15
17Item 16
18Item 17
19Item 18
20Item 19
21Item 20
22Item 21
23Item 22
24Item 23
25Item 24
26Item 25
27
Transpose





Macro approach:

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> Transpose_Data()<br>    <SPAN style="color:#00007F">Dim</SPAN> r <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, LR <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, nr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    <SPAN style="color:#00007F">Const</SPAN> BlockSize <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN> = 5<br>    <SPAN style="color:#00007F">Const</SPAN> DestCol <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "D"<br>    <SPAN style="color:#00007F">Const</SPAN> DestFirstRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN> = 2<br>    <br>    LR = Range("A" & Rows.Count).End(xlUp).Row<br>    nr = DestFirstRow<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> r = 2 <SPAN style="color:#00007F">To</SPAN> LR <SPAN style="color:#00007F">Step</SPAN> BlockSize<br>        Cells(nr, DestCol).Resize(, BlockSize).Value = _<br>            Application.Transpose(Cells(r, "A").Resize(BlockSize).Value)<br>        nr = nr + 1<br>    <SPAN style="color:#00007F">Next</SPAN> r<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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