+ Reply to Thread
Results 1 to 5 of 5

Macro to transpose multiple rows into one row

  1. #1
    Registered User
    Join Date
    09-13-2019
    Location
    US
    MS-Off Ver
    office 365
    Posts
    26

    Macro to transpose multiple rows into one row

    Hello all,

    I'm wondering if this is possible. Here is a sample of a large data set:
    Capture.PNG

    I want to transpose these multiple rows into one row per service, id, name, age, street address with multiple phone numbers like this:
    Capture1.PNG

    Thank you guys
    Attached Files Attached Files

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Macro to transpose multiple rows into one row

    Your expected results sample does not match your narrative objective. Which do you want to use? Or do you want to redo your expected results.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Macro to transpose multiple rows into one row

    Like this perhaps? To test run macro "GetData" but still as JLG said your data is inconsistent as some of the persons have two different service so should there not be two lines in that case?

    Alf
    Attached Files Attached Files

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Macro to transpose multiple rows into one row

    Thanks for feedback and rep.

    As I said before I find your data inconsistent and that the result from my macro matches your demand is caused by the fact that macro copies range B1:F18 three rows below your original data. It then deletes all duplicates in column C and D. So this means the first values in C and D are 110 and Jack are kept the rest of the data for 110 and Jack is deleted. Since the first row of this data contains service "Verizone" this is what is added to Jacks profile. If the service column was sorted alphabetically then "Sprint" would be the service assigned to Jack.

    For Mary this does not matter as she only has one service provider but for John who has 3 "Verizone" and three "ATT" a sorting on service provider in alphbetical order would in this case assign ATT to John.

    Alf

  5. #5
    Registered User
    Join Date
    09-13-2019
    Location
    US
    MS-Off Ver
    office 365
    Posts
    26

    Re: Macro to transpose multiple rows into one row

    Quote Originally Posted by Alf View Post
    Thanks for feedback and rep.

    As I said before I find your data inconsistent and that the result from my macro matches your demand is caused by the fact that macro copies range B1:F18 three rows below your original data. It then deletes all duplicates in column C and D. So this means the first values in C and D are 110 and Jack are kept the rest of the data for 110 and Jack is deleted. Since the first row of this data contains service "Verizone" this is what is added to Jacks profile. If the service column was sorted alphabetically then "Sprint" would be the service assigned to Jack.

    For Mary this does not matter as she only has one service provider but for John who has 3 "Verizone" and three "ATT" a sorting on service provider in alphbetical order would in this case assign ATT to John.

    Alf
    Sorry about that. I appreciate your help and thank you for explaining to me

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy and paste macro that will transpose info from multiple rows
    By elkoutdoorsman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-06-2017, 10:39 AM
  2. [SOLVED] Macro to transpose multiple rows to a single column
    By Gup in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 10-12-2014, 03:05 PM
  3. [SOLVED] Transpose Multiple Rows into a Single Row and Randomize in the Same Macro
    By bwalks in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-07-2014, 08:37 PM
  4. [SOLVED] Macro to transpose data from two columns into multiple rows
    By Wolopter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2014, 07:18 AM
  5. [SOLVED] Macro to transpose data from two columns into multiple rows
    By Briansva92 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-27-2012, 07:55 PM
  6. Macro to transpose one column into multiple rows over MANY lines of data?
    By mtc in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-24-2012, 10:34 PM
  7. Macro to Transpose multiple rows to one colums
    By Karina in forum Excel General
    Replies: 2
    Last Post: 08-27-2011, 12:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1