+ Reply to Thread
Results 1 to 3 of 3

Combine row data based on Duplicate ID

  1. #1
    Registered User
    Join Date
    04-19-2011
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2003
    Posts
    7

    Question Combine row data based on Duplicate ID

    ID-SSN City Pet1 Pet2 Pet3 Pet4
    111-11-1111 Baltimore Dog Bird
    111-11-1111 Cow
    777-77-7777 Augusta Cat Horse
    777-77-7777 Dog
    777-77-7777 Cow

    I am trying to MASH UP rows with duplicate ID-SSNs.
    End result would be:

    ID-SSN City Pet1 Pet2 Pet3 Pet4
    111-11-1111 Baltimore Dog Cow Bird
    777-77-7777 Augusta Cat Dog Horse Cow

    Any advise. I'm really stuck. Tried some nested IF statements to no avail.
    Any help is GREATLY APPRICIATED! Michelle

    The sample above didn't post visually as I had hoped. The "cow" entry for 2nd line of 111-11-111 should show as being located in the Pet3 column.
    For row 4 777-77-7777 Dog is located in Pet2 and row 5 777-77-777 Cow is located in Pet4. Hope I haven't confused you further..ugh.
    Last edited by mlgill; 06-17-2011 at 04:21 PM.

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Combine row data based on Duplicate ID

    hi,

    let your data are in column A in activesheet
    try this code:
    Please Login or Register  to view this content.
    Best Regards

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Combine row data based on Duplicate ID

    Hello mlgill,

    The attached workbook has the following macro attached to a button that runs it. I tried to cover as many possible scenarios that might arise. The code is rather long but is heavily commented.

    The macro will allow and track multiple cities for one social security number. If there are more than 4 pets per SSN, the user is alerted, the cells are highlighted in yellow, and the macro stops so the data can be corrected.

    An entry will not be recorded if it is the first entry for a SSN and there is no city. After a city has been entered, if the city is absent then the previous city for that SSN is used.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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