+ Reply to Thread
Results 1 to 9 of 9

Merging rows based on duplicate values in VBA

  1. #1
    Registered User
    Join Date
    01-15-2018
    Location
    Calgary
    MS-Off Ver
    2010
    Posts
    6

    Merging rows based on duplicate values in VBA

    Hello,
    I am needing some help combining rows which have a duplicate unique ID in VBA.
    Please see the following example

    Unique ID (Column A) Constructive Placement Date (Column B) Actual Placement date (Column C)
    NDYX89207011/25/2017 18:38:00 11/25/2017
    NAHX32023512/14/2017 13:01:00
    11/25/2017
    CAIX09567612/30/2017 21:55:00 11/25/2017
    NDYX89207011/25/2017 18:38:00 11/25/2017 12/25/2017
    CAIX09567612/30/2017 21:55:00 11/25/2017 12/25/2017

    So basically what I need to do is combine the rows with the duplicate unique ID's so that the row reflects the the actual placement date. Also if there is no actual placement date, the actual placement date column stays blank
    I have tried doing nested loops, and using formulas on the work sheet to merge these rows together, but nothing's working
    Also there is a lot more records than just the few in the table
    Any help would be great!
    Thanks
    Last edited by dkemp354; 01-15-2018 at 07:18 PM.

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

    Re: Merging rows based on duplicate values in VBA

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Thanks,
    Mike

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

  3. #3
    Registered User
    Join Date
    01-15-2018
    Location
    Calgary
    MS-Off Ver
    2010
    Posts
    6

    Re: Merging rows based on duplicate values in VBA

    Hi Mike,
    I just uploaded the file.
    It shows what the original sheet will look like vs desired results
    Thanks
    Attached Files Attached Files

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

    Re: Merging rows based on duplicate values in VBA

    Something like this maybe

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-15-2018
    Location
    Calgary
    MS-Off Ver
    2010
    Posts
    6

    Re: Merging rows based on duplicate values in VBA

    Hi Mike,
    Thanks for the response.
    I actually don't want to have new sheets created every time the macro is run.
    I'm just looking to combine the cells with the same ID to reflect the actual placement date whether that field is blank or not all on the same sheet.
    So on the workbook I provided, I would like to see duplicate rows combined all on the one sheet
    Thanks

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

    Re: Merging rows based on duplicate values in VBA

    This what your wanting?

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-15-2018
    Location
    Calgary
    MS-Off Ver
    2010
    Posts
    6

    Re: Merging rows based on duplicate values in VBA

    Hi Mike.
    Thanks it works!
    However when this macro is run I lose my formulas in my spreadsheet.
    I forgot to add them to the other workbook. Is there any way to keep these formulas, or add them in after this macro is run?
    I have attached the spreadsheet with the formulas
    If you look at column H,J K they all have formulas. When the macro is run, I lose the formulas in the cell, and incorrect data is displayed

    Thanks
    Attached Files Attached Files

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

    Re: Merging rows based on duplicate values in VBA

    One way
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-15-2018
    Location
    Calgary
    MS-Off Ver
    2010
    Posts
    6

    Re: Merging rows based on duplicate values in VBA

    Awesome!
    It works well
    Fixed my formatting issue as well
    Thanks for the help!
    Last edited by dkemp354; 01-17-2018 at 01:12 PM.

+ 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. [SOLVED] Delete rows based on duplicate column values?
    By Casey825 in forum Excel General
    Replies: 11
    Last Post: 12-19-2017, 07:10 PM
  2. [SOLVED] SUM values based on duplicate rows?
    By spiphix in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-17-2016, 07:33 PM
  3. [SOLVED] Combining Rows - Keeping Unique and "New" Values & Merging Duplicate Values
    By kimbekaw in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-21-2014, 05:30 PM
  4. Remove Duplicate Rows based on Specific Values
    By zeanzi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-31-2013, 08:01 PM
  5. Need CONCACTENATE Duplicate Rows based on specific values
    By YesSir1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-14-2013, 01:14 PM
  6. Duplicate Rows based on cell values
    By rifitintaken in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2010, 09:54 AM
  7. Replies: 4
    Last Post: 06-26-2009, 08:11 PM

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