We help IT Professionals succeed at work.

Convert subset of columns to rows and replicating the others in Excel

I have columns A to IV where Column A is unique and all the other columns are related to A eg
A = Group X, coliumns B to IV are individual people that belong to Group A. I need to do vairous calculates for each Agent and which groups be belongs to so I think the easiest is to convert them into rows?

Group 1, John, Tom, Harry
Group 2, John, Alan, Bob
Group1, John
Group1, Tom
Group1, Harry
Group2, John
Group2, Alan
Group2, Bob
Watch Question

This macro will transpose the data from sheet1 range A1 onwards to sheet2

Sub colgroups2rows()
    Dim rw As Range
    Dim cel As Range
    For Each rw In Sheet1.Range("A1:A" & Sheet1.Range("A1").End(xlDown).Row)
        For Each cel In Range(rw.Offset(, 1), rw.End(xlToRight))
            Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1, 1) = cel
            Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1) = rw
        Next cel
    Next rw
End Sub


Saqib I tried the macro (see attached) but it seems to hang and never complete?

I found no macro in the attached file.

I attached the macro to your file. It worked just fine.

Here is the file with the macro. Try it.


this worked great thank you