+ Reply to Thread
Results 1 to 15 of 15

Combine entries and delete entire rows

  1. #1
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Post Combine entries and delete entire rows

    Hello,
    I am quite new in the forum and hope, you can help me urgently with a handy macro to solve my problem:
    In case of duplicates in first column, entries of other duplicates are merged in the second column with a separator; the row with first duplicate is kept and the rows with the remaining ones are removed.
    Before:
    A £ name1 address1
    D $ name2 address2
    C # name3 address3
    A £ name4 address4
    B % name5 address5
    D # name6 address6

    After:
    A £ name1 address1
    D $,# name2 address2
    C # name3 address3
    B % name5 address5

    Many thanks in advance
    Niclal
    Last edited by Niclal; 10-07-2012 at 10:34 AM.

  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: Combine entries and delete entire rows

    If you could upload a workbook with the before and after results it would help you get help faster.
    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
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Combine entries and delete entire rows

    Hello All,
    I've attached an example.
    Regards,
    Niclal
    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: Combine entries and delete entire rows

    Give this a try

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Combine entries and delete entire rows

    I had a go as well, but Mike's one is better
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Combine entries and delete entire rows

    Mike,
    should not this line be "comma"
    Please Login or Register  to view this content.
    should be

    Please Login or Register  to view this content.

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

    Re: Combine entries and delete entire rows

    Hello,
    I am quite new in the forum and hope, you can help me urgently with a handy macro to solve my problem:
    In case of duplicates in first column, entries of other duplicates are merged in the second column with a separator; the row with first duplicate is kept and the rows with the remaining ones are removed.
    I dont believe so.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Combine entries and delete entire rows

    Mike,
    you may be right! I am only going by the result on the attached sheet

    If you look at the attached after result, you get these data. I thought there is "," not ";"
    After
    A $,# Name1 city1 zipcode1
    C ?,%,£ Name2 city2 zipcode2
    D # Name3 city3 zipcode3
    B ? Name4 city4 zipcode4

  9. #9
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Combine entries and delete entire rows

    Hi Mike, AB33,
    Thanks very much. Much appreciated; it really doesn't matter to use ";" or "," as separator.
    One question, if I have a 6th column and the first row as Header, how would I change the macro?
    Thanks
    Niclal

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

    Re: Combine entries and delete entire rows

    Try this

    Please Login or Register  to view this content.
    Last edited by mike7952; 10-07-2012 at 02:07 PM.

  11. #11
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Combine entries and delete entire rows

    Mike,
    I've got an error message: run-time error-subscript out of range, maybe because I have more that 500 rows.
    In addition, I have 2 questions:
    1) after merging, entries should be unique, e.g. check results for "A".
    instead of:

    Column1 Column2 Column3 Column4 Column5 Column6
    A $;$;# Name1 city1 zipcode1 address1
    C ?;%;£ Name2 city2 zipcode2 address2
    D # Name3 city3 zipcode3 address3
    B ? Name4 city4 zipcode4 address4

    The results should be:

    Column1 Column2 Column3 Column4 Column5 Column6
    A $;# Name1 city1 zipcode1 address1
    C ?;%;£ Name2 city2 zipcode2 address2
    D # Name3 city3 zipcode3 address3
    B ? Name4 city4 zipcode4 address4


    2) I want to learn and so, how should the macro be changed if I have ,say, only 3 columns?

    Thanks very much for your efforts

    Niclal
    Last edited by Niclal; 10-08-2012 at 02:37 AM.

  12. #12
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Combine entries and delete entire rows

    Dear Mike,
    Any thoughts on my request? Sorry whan I ask again, I need it really urgently.
    Thanks,
    Niclal

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

    Re: Combine entries and delete entire rows

    Does this help. The runtime error is probably you dont have a Worksheet named Sheet1. Just change it in the code where comment is

    Please Login or Register  to view this content.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Combine entries and delete entire rows

    A very similar codes are found these days, even the variable names.....

    Niclal,
    try
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Combine entries and delete entire rows

    Mike, Jindon,
    You all rock! Thank you very much!
    Niclal

+ 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