How to transpose a columns into lists with subsets

andrea1982

New Member
Joined
Apr 13, 2017
Messages
1
:eeek:

Does anyone knows how could I transpose 32,000 rows and stack several columns (same category, employees) in one column in the following way?

[TABLE="width: 435"]
<tbody>[TR]
[TD="class: xl63, width: 87, align: center"]Company[/TD]
[TD="class: xl63, width: 87, align: center"]Employee[/TD]
[TD="class: xl63, width: 87, align: center"]Employee[/TD]
[TD="class: xl63, width: 87, align: center"]Employee[/TD]
[TD="class: xl63, width: 87, align: center"]Employee[/TD]
[/TR]
[TR]
[TD="class: xl64, align: center"]1[/TD]
[TD="class: xl64, align: center"]A[/TD]
[TD="class: xl64, align: center"]B[/TD]
[TD="class: xl64, align: center"]C[/TD]
[TD="class: xl64, align: center"]D[/TD]
[/TR]
[TR]
[TD="class: xl64, align: center"]2[/TD]
[TD="class: xl64, align: center"]D[/TD]
[TD="class: xl64, align: center"]A[/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[/TR]
[TR]
[TD="class: xl64, align: center"]3[/TD]
[TD="class: xl64, align: center"]E[/TD]
[TD="class: xl64, align: center"]F[/TD]
[TD="class: xl64, align: center"]A[/TD]
[TD="class: xl64, align: center"][/TD]
[/TR]
[TR]
[TD="class: xl64, align: center"]…[/TD]
[TD="class: xl64, align: center"]…[/TD]
[TD="class: xl64, align: center"]…[/TD]
[TD="class: xl64, align: center"]…[/TD]
[TD="class: xl64, align: center"]…[/TD]
[/TR]
[TR]
[TD="class: xl64, align: center"]32,000[/TD]
[TD="class: xl64, align: center"]F[/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[TD="class: xl64, align: center"][/TD]
[/TR]
</tbody>[/TABLE]


to

[TABLE="width: 174"]
<tbody>[TR]
[TD="class: xl63, width: 87, align: center"]Company[/TD]
[TD="class: xl63, width: 87, align: center"]Employee[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]1[/TD]
[TD="class: xl63, align: center"]A[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]1[/TD]
[TD="class: xl63, align: center"]B[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]1[/TD]
[TD="class: xl63, align: center"]C[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]1[/TD]
[TD="class: xl63, align: center"]D[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]2[/TD]
[TD="class: xl63, align: center"]D[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]2[/TD]
[TD="class: xl63, align: center"]A[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]3[/TD]
[TD="class: xl63, align: center"]E[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]3[/TD]
[TD="class: xl63, align: center"]F[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]3[/TD]
[TD="class: xl63, align: center"]A[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]…[/TD]
[TD="class: xl64, align: center"]…[/TD]
[/TR]
[TR]
[TD="class: xl63, align: center"]32000[/TD]
[TD="class: xl64, align: center"]F[/TD]
[/TR]
</tbody>[/TABLE]
<style><!--table {mso-displayed-decimal-separator:"\."; mso-displayed-thousand-separator:"\,";}@page {margin:.75in .7in .75in .7in; mso-header-margin:.3in; mso-footer-margin:.3in;}td {padding-top:1px; padding-right:1px; padding-left:1px; mso-ignore:padding; color:black; font-size:12.0pt; font-weight:400; font-style:normal; text-decoration:none; font-family:Calibri, sans-serif; mso-font-charset:0; mso-number-format:General; text-align:general; vertical-align:bottom; border:none; mso-background-source:auto; mso-pattern:auto; mso-protection:locked visible; white-space:nowrap; mso-rotate:0;}.xl63 {border:.5pt solid windowtext;}.xl64 {text-align:center; border:.5pt solid windowtext;}--></style><style><!--table {mso-displayed-decimal-separator:"\."; mso-displayed-thousand-separator:"\,";}@page {margin:.75in .7in .75in .7in; mso-header-margin:.3in; mso-footer-margin:.3in;}td {padding-top:1px; padding-right:1px; padding-left:1px; mso-ignore:padding; color:black; font-size:12.0pt; font-weight:400; font-style:normal; text-decoration:none; font-family:Calibri, sans-serif; mso-font-charset:0; mso-number-format:General; text-align:general; vertical-align:bottom; border:none; mso-background-source:auto; mso-pattern:auto; mso-protection:locked visible; white-space:nowrap; mso-rotate:0;}.xl63 {text-align:center; border:.5pt solid windowtext;}.xl64 {color:black; text-align:center; border:.5pt solid windowtext;}--></style>
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
andrea1982,

Welcome to the Board.

If you're comfortable with a vba approach, you might consider the following...

Code:
Sub ResizeEmployees()
Application.ScreenUpdating = False
Dim LastRow1 As Long, LastRow2 As Long, LastColumn As Long, i As Long, j As Long, k As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Sheets(1)
Set ws2 = Sheets.Add(after:=ws1)
LastRow1 = ws1.Cells(Rows.Count, 1).End(xlUp).Row
ws2.Range("A1:B1").Value = ws1.Range("A1:B1").Value
For i = 2 To LastRow1
    LastColumn = ws1.Cells(i, Columns.Count).End(xlToLeft).Column
    LastRow2 = ws2.Cells(Rows.Count, 1).End(xlUp).Row + 1
    ws1.Cells(i, 1).Copy
    ws2.Cells(LastRow2, 1).Resize((LastColumn - 1), 1).Insert
    k = 0
    For j = 2 To LastColumn
        ws2.Cells(LastRow2 + k, 2).Value = ws1.Cells(i, j).Value
        k = k + 1
    Next j
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub

The code adds a worksheet to accommodate the transposed data.

Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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