+ Reply to Thread
Results 1 to 18 of 18

Combine multiple records onto one row based on unique name/surname in the first column

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Combine multiple records onto one row based on unique name/surname in the first column

    I am trying to convert duplicate data in columns into single rows BUT extracting the relevant data at the same time.
    Here I am uploading a sample in excel of what i really want to do.

    Thank you
    Attached Files Attached Files
    Last edited by Anita7; 09-11-2012 at 02:15 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to convert duplicated data in multiple columns into single rows?

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: How to convert duplicated data in multiple columns into single rows?

    Hi Arlette,
    Thank you but it seems that it's not working for me yet...
    I ran it with a file with 100 rows and I ended up with 5 ones :SS
    I'm new at VBA and I can't explain what is wrong...

  4. #4
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: How to convert duplicated data in multiple columns into single rows?

    And when I try to run it with the sample which I have uploaded above the result is this:

    Ann White 100
    Julia Brown 100
    Johny Blue 100
    Julia Brown 200
    Johny Blue 300

    PS: Should I copy the code in a worksheet containing data or first copy/paste the code and pasting the data afterwards?

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    Did you put the code in a standard module?

    You need to put the code first, then run the macro on the data.

  6. #6
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    Yes, I got that but I don't understand if the worksheet on which I'm going to run the macro should be blank before I copy the code or it doesn't matter?
    This is how it looks like the VIsual BAsic Editor. Visual Basic Editor.jpg
    Thank you )

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    The code can be copied either before or after the data.

  8. #8
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    But what is wrong? I'm uploading again the sample but with the code in it this time.
    I don't get what I want..:S
    Attached Files Attached Files
    Last edited by Anita7; 09-12-2012 at 02:13 PM.

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    The reason why its not working is because your earlier sample file had data in columns B & C. Hence, the code was created based on that.

    Here is the updated code as per your updated sample file -
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    Thank you so much Arlette,
    Can I use this code on a sheet with 4thousand rows? May it cause any problem?

    PS:In my case I need more than two records associated with the name in the first column.
    Is there any need to make a change in the code?
    for example: Ann White 100 200 300 500 and so on
    Last edited by Anita7; 09-12-2012 at 03:08 PM.

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    You can use it on any number of rows. It wont cause any problem.

  12. #12
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    Ok
    What about the other question?
    It looks like it is causing me some problems...
    Thanks again

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    I have to re-work the code a bit.

  14. #14
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    Please can you do that for me?
    Thank you so MUCH )

  15. #15
    Registered User
    Join Date
    07-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007/2010
    Posts
    86

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    I modified the code. See if it works.
    Please Login or Register  to view this content.
    Boon

  16. #16
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    See if this will work for you
    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  17. #17
    Registered User
    Join Date
    07-30-2012
    Location
    Tirane, Albania
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    Yes, it really works )))
    Thank you sooooooo much @Mike and Boon
    How can I mark it as solved?
    Last edited by Anita7; 09-13-2012 at 06:29 AM.

  18. #18
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Combine multiple records onto one row based on unique name/surname in the first column

    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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