Simple Transpose problem

Maajid

New Member
Joined
Mar 8, 2019
Messages
2
Hello everyone,

I have a very simple transpose problem that I can't quite figure out. The data I have is currently in this format:


NameResponse
Respondent 1X
Y
Z
Respondent 2A
B
C
D

<tbody>
</tbody>


I want to transpose it so it is in the following format:

NameResponse 1Response 2Response 4Response 5
Respondent 1XYZ
Respondent 2ABCD

<tbody>
</tbody>


I know I can easily do this copying and pasting but the number of respondents is almost 2,000 and it wouldn't be possible to individually paste each respondent's responses and applying a transpose. If anyone has any ideas as to how to do this quickly, I'd be grateful.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
you can try PowerQuery (Get&Transform)
(simple version)

NameResponseNameResponse.1Response.2Response.3Response.4
Respondent 1XRespondent 1XYZ
YRespondent 2ABCD
Z
Respondent 2A
B
C
D

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Filled Down" = Table.FillDown(Source,{"Name"}),
    #"Grouped Rows" = Table.Group(#"Filled Down", {"Name"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Response", each Table.Column([Count],"Response")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Response", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Response", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Response.1", "Response.2", "Response.3", "Response.4"})
in
    #"Split Column by Delimiter"[/SIZE]
 
Upvote 0
Thank you for the swift reply, I really appreciate it.

I am using Excel for Mac 2019 though and from what I can see, the PowerQuery add-in is not available for the Mac version of Excel. Is there an alternative to this?

Thanks again.
 
Upvote 0
try this


Book1
ABCDEFGH
1NameResponseNameResponse 1Response 2Response 3Response 4
2Respondent 1XRespondent 1XYZ
3YRespondent 2ABCD
4ZRespondent 3GH
5Respondent 2A
6B
7C
8D
9Respondent 3G
10H
81
Cell Formulas
RangeFormula
E2=IF((COLUMN(E$1)-COLUMN($D$1))>SUMPRODUCT(--(LOOKUP(ROW($A$2:$A$2000),ROW($A$2:$A$2000)/($A$2:$A$2000>0),$A$2:$A$2000)=$D2)),"",OFFSET($A$1,MATCH($D2,$A:$A,0)+COLUMN(E$1)-COLUMN($F$1),1))
 
Upvote 0
Another way :
Code:
Sub RwsToCols()
Dim r%: r = 2
Dim c: c = 3
Application.ScreenUpdating = False
Do While Not IsEmpty(Cells(r, 2))
    If IsEmpty(Cells(r, 1)) Then
        Cells(r - 1, c) = Cells(r, 2)
        Rows(r).Delete Shift:=xlUp
        c = c + 1
    Else
        c = 3
        r = r + 1
    End If
Loop
End Sub
 
Upvote 0
I'm not sure if it works on mac, but put your data on sheet1 and create a sheet called "sheet2"

Run this macro:

Code:
Sub Macro2()
    Dim sh1 As Worksheet, sh2 As Worksheet, wArea As Range, rArea As Range
    
    Set sh1 = Sheets("Sheet1")
    Set sh2 = Sheets("Sheet2")
    sh2.Cells.ClearContents
    For Each wArea In sh1.Range("A2", sh1.Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlanks).Areas
        Set rArea = wArea.Resize(wArea.Rows.Count + 1).Offset(-1, 1)
        sh2.Range("A" & Rows.Count).End(xlUp).Offset(1).Value = wArea.Offset(-1, 0).Value
        sh2.Range("B" & Rows.Count).End(xlUp).Offset(1).Resize(1, rArea.Count) = WorksheetFunction.Transpose(rArea.Value)
    Next
    MsgBox "End"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,665
Messages
6,120,804
Members
448,990
Latest member
rohitsomani

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