Transpose Data from rows to columns

noclue88

New Member
Joined
Aug 5, 2013
Messages
4
Hello,<o:p></o:p>
I’m trying to transpose the following information in Excel 2010:<o:p></o:p>
[TABLE="class: MsoTableGrid"]
<TBODY>[TR]
[TD="width: 607, bgcolor: transparent"]UAMS Family Medical Center Fort Smith-AHEC WEST<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]612 South 12th Street<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]Fort Smith, AR 72901<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]UAMS Internal Medicine North Clinic<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]4301 W. Markham, Slot 641<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]Little Rock, AR 72205<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]UAMS Internal Medicine South<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]4301 W. Markham, STE 547-15<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 607, bgcolor: transparent"]Little Rock, AR 72205-7199<o:p></o:p>
[/TD]
[/TR]
</TBODY>[/TABLE]
<o:p> </o:p>
To look like this: <o:p></o:p>
[TABLE="class: MsoTableGrid"]
<TBODY>[TR]
[TD="width: 222, bgcolor: transparent"]UAMS Family Medical Center Fort Smith-AHEC WEST<o:p></o:p>
[/TD]
[TD="width: 186, bgcolor: transparent"]612 South 12th Street<o:p></o:p>
[/TD]
[TD="width: 162, bgcolor: transparent"]Fort Smith, AR 72901<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 222, bgcolor: transparent"]UAMS Internal Medicine North Clinic<o:p></o:p>
[/TD]
[TD="width: 186, bgcolor: transparent"]4301 W. Markham, Slot 641<o:p></o:p>
[/TD]
[TD="width: 162, bgcolor: transparent"]Little Rock, AR 72205<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 222, bgcolor: transparent"]UAMS Internal Medicine South<o:p></o:p>
[/TD]
[TD="width: 186, bgcolor: transparent"]4301 W. Markham, STE 547-15<o:p></o:p>
[/TD]
[TD="width: 162, bgcolor: transparent"]Little Rock, AR 72205-7199<o:p></o:p>
[/TD]
[/TR]
</TBODY>[/TABLE]
<o:p> </o:p>
The only catch is that there are 21051 rows of this. <o:p></o:p>
So to be clear, the second and third rows need to be transposed in the first row and deleted (if possible).<o:p></o:p>
The fields are “Facility”, “Address”, “Zip”.<o:p></o:p>
Some VBA or macro would be ideal here, however, I just don’t know how to do it.<o:p></o:p>
Thanks for your help! Let me know if I need to clarify.<o:p></o:p>
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
This macro should work just about as fast as is possible to process all that data...

Code:
Sub TransposeData()
  Dim X As Long, LastRow As Long, DataIn As Variant, DataOut As Variant
  Const StartRow As Long = 1
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  DataIn = Cells(StartRow, "A").Resize(LastRow - StartRow + 1)
  ReDim DataOut(1 To UBound(DataIn) \ 3, 1 To 3)
  For X = StartRow To LastRow Step 3
    DataOut(1 + X \ 3, 1) = DataIn(X, 1)
    DataOut(1 + X \ 3, 2) = DataIn(X + 1, 1)
    DataOut(1 + X \ 3, 3) = DataIn(X + 2, 1)
  Next
  Columns("A").Clear
  Cells(StartRow, "A").Resize(UBound(DataIn) \ 3, 3) = DataOut
End Sub

The only thing you might have to change is the value assigned to the StartRow constant (the Const statement)... that needs to be the row number for your first piece of data.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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