Results 1 to 7 of 7

Sub to remove duplicate IDs and combine multiple lookup results into single cells

Threaded View

  1. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Sub to remove duplicate IDs and combine multiple lookup results into single cells

    hi there. do upload an excel sample so that we do not have to manually key in your data to do a testing.

    try this code here:
    Sub test()
    
    LR = Cells(Rows.Count, 1).End(xlUp).Row
    
    With Sheets("Desired Output")
        .Cells(1, 1).Resize(LR, 2) = Cells(1, 1).Resize(LR, 2).Value
        For RowX = LR To 2 Step -1
            If .Cells(RowX, 1) = .Cells(RowX - 1, 1) Then
                .Cells(RowX - 1, "B") = .Cells(RowX - 1, "B") & "," & .Cells(RowX, "B")
                .Rows(RowX).Delete
            End If
        Next
        .Activate
    End With
    
    MsgBox "Done!"
    
    End Sub
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need to combine cells to one string of text if duplicate values exist in multiple cells
    By Chris McGlothen in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-17-2017, 09:13 PM
  2. Sort Query Results to remove duplicate entries and put results on one line.
    By Panther70 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2015, 03:03 PM
  3. [SOLVED] Combine Multiple sections into single cells
    By flexi1 in forum Excel General
    Replies: 9
    Last Post: 02-23-2015, 09:30 AM
  4. [SOLVED] Combine multiple ALMOST duplicate rows into a single row
    By Styler001 in forum Excel General
    Replies: 3
    Last Post: 07-31-2014, 02:30 AM
  5. Replies: 1
    Last Post: 09-06-2013, 10:05 AM
  6. Replies: 8
    Last Post: 04-12-2012, 08:02 PM
  7. [SOLVED] lookup multiple values of a single cell and return sum of results
    By Zeppelin17 in forum Excel General
    Replies: 7
    Last Post: 08-10-2011, 07:09 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