Transpose columns to rows with a twist

MPFraser7

New Member
Joined
Dec 14, 2016
Messages
34
User

App1
App2
App3
A
Safari
Chrome
B
Safari
Edge
C
Chrome

<tbody>
</tbody>

I have a similar table in excel, and I want to quickly convert it to this:

User App
A Safari
A Chrome
B Safari
B Edge
C Chrome

Any ideas?
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Sorry, I couldn't add a second table but there are 2 columns: User and App, and 6 rows. Since user A has access to two apps, there are two rows for him. Let me know if this isn't clear.
 
Upvote 0
How about using Power Query, can be done quick with the Unpivot Columns command
 
Upvote 0
VBA solution, input on Sheet1, output on Sheet2

Code:
Sub k1()
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
k = 0
For i = 2 To lastrow
For j = 2 To 4
If Worksheets("Sheet1").Cells(i, j) <> "" Then
    k = k + 1
    Worksheets("Sheet2").Cells(k, 1) = Worksheets("Sheet1").Cells(i, 1)
    Worksheets("Sheet2").Cells(k, 2) = Worksheets("Sheet1").Cells(i, j)
End If
Next j
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,814
Messages
6,121,711
Members
449,049
Latest member
THMarana

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