• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

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
so
Group1, John
Group1, Tom
Group1, Harry
Group2, John
Group2, Alan
Group2, Bob
0
pcomb
Asked:
pcomb
  • 2
  • 2
1 Solution
 
Saqib Husain, SyedEngineerCommented:
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
0
 
pcombAuthor Commented:
Saqib I tried the macro (see attached) but it seems to hang and never complete?

thanks
AgentGroups-tst.xlsm
0
 
Saqib Husain, SyedEngineerCommented:
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.
AgentGroups-tst.xlsm
0
 
pcombAuthor Commented:
this worked great thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now