+ Reply to Thread
Results 1 to 28 of 28

Merge cells in corresponding column based on similar values

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

    Merge cells in corresponding column based on similar values

    Hello Everybody,
    I would like to merge cells in different columns based on similar values in column "FN".
    The attachment shows you how the result should look like.
    Thank you very much for your support.
    Niclal
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Is only column "D" the one to merge?
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Try

    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Merge cells in corresponding column based on similar values

    Hi,
    All columns "Fil", "Gra", "Inac", "Doc" have to be merged.
    Thank you

    Niclal

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    So, what about the macro sent?

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

    Re: Merge cells in corresponding column based on similar values

    Hi,
    This is exactly what I need. Would it be possible to have the results replace the original data instead of putting them in the sheet "After". The column headers are in the first row starting in A1.
    Thank you so much in advance.
    N

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    To change the sheets used is not a big deal:
    from where the data is coming from:
    Please Login or Register  to view this content.
    change "Before" by the name of the sheet to use

    where to put the data:
    Please Login or Register  to view this content.
    change "After" by the name of the sheet to use
    Attached Files Attached Files
    Last edited by PCI; 11-21-2014 at 08:24 PM.

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    An update to be clean and smart


    Please Login or Register  to view this content.

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

    Re: Merge cells in corresponding column based on similar values

    Dear PCI,
    one last question:
    the location of the columns have been changed: column "FN" is now in column B, column "Fil", "Gra", "Ina", "Doc" are respective in column W, X, Y, Z. How should the code be revised?
    Thank you very much

    Capture.JPG

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    See how it works

    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Merge cells in corresponding column based on similar values

    Hi PCI,
    I am afraid, there is one piece of information I didn't mention: Column A as well as columns C to V has also content. After running the macro only one row (the first) should remain with information; all other duplicate rows should be removed.
    Thank you so much

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Can you send an update of your example showing sheet "Before" and "After".

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

    Re: Merge cells in corresponding column based on similar values

    Hi PCI,
    I have now included an update of my table showing "Before" and "After" as tabs.
    I really appreciate your time and help.
    N
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    See how next code works

    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Merge cells in corresponding column based on similar values

    Hi PCI,
    When I test it with a similar table with the same column headers but more text, I get the error message "Run-time error 13 Type Mismatch" at the line "WSDest.Range("A2").Resize(.Count, 26) = Application.Transpose(Application.Transpose(.items))"
    Any thoughts?
    Thank you
    N

  16. #16
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Niclal,
    Here again it will be really easier to have a sample of the file to see the problem: Can you?
    When you say "more text" does it means more data inside one cell or more cells?
    PCI

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

    Re: Merge cells in corresponding column based on similar values

    Hi PCI,
    I fully understand that, but unfortunately, I cannot make the text public, and that's why I am trying to describe the content. The number of columns is the same as in Book2, I have around 1000 rows, the cells in the first column contain hyperlinks, and I have sometimes more data inside one cell.
    I cannot tell how much I appreciate your help.

    N

  18. #18
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Give a chance to the file attached.
    But of course the hyperlink will not be copied, only the cells' value
    Attached Files Attached Files
    Last edited by PCI; 11-26-2014 at 03:11 PM.

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

    Re: Merge cells in corresponding column based on similar values

    Dear PCI,
    Unfortunately, I still get the error message "Run-time error 13 - Type Mismatch" on line "WSDest.Range("A2").Resize(.Count, 26) = Application.Transpose(Application.Transpose(.items))"
    Regards,
    N

  20. #20
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    The macro is working with the sample file you sent and not with real one, is it?
    Can you prepare a test file (with dummy data) reproducing the issue?

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

    Re: Merge cells in corresponding column based on similar values

    Dear PCI,
    Good day! I have prepared a test file to demonstrate the error message I get.
    Many thanks for your help
    N
    Attached Files Attached Files

  22. #22
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Try with your file attached
    Attached Files Attached Files

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

    Re: Merge cells in corresponding column based on similar values

    Dear PCI,
    I would like to really thank you for the awesome help. You rock!
    One last wish I have before closing this post: Could you please take a look at the column T in the attachment and revise your macro accordingly.
    Thanks a bunch in advance.

    N
    Attached Files Attached Files

  24. #24
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Not sure to get it right.
    It looks that between the result expected and the result from the macro there is a difference concerning linl1 and link6.
    But for me the result (from the macro) is correct.
    Please explain
    Attached Files Attached Files

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

    Re: Merge cells in corresponding column based on similar values

    Dear PCI,
    My last question is about how to merge the values in column col20.
    Let's take 2 examples:
    In column FN, we have 3 "1001" and 4 "2011" ; for "1001" the corresponding values in column col20 are "0", blank, "1"; for "2011" the corresponding values in column col20 are "1", "1", "1", "1".
    If the values contain at least one "1", then "1" is taken. If there is no "1", then "0" is taken.
    In our 2 examples, that means: for the FN value "1001", the corresponding value in col20 is "1"; for the FN value "2011", the corresponding value in col20 is "1";
    I hope, this is now clear.
    Thanks a lot

    N

  26. #26
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    Try the file attached.
    It is not exactly the same result: See for 2014
    Note, for column 20 the result will never be "", only 0 or 1
    Attached Files Attached Files

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

    Re: Merge cells in corresponding column based on similar values

    Hi PCI,
    I'd like to thank you again for the great help you provided to me.
    Thank you so much.
    N

  28. #28
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Merge cells in corresponding column based on similar values

    You're welcome.
    Thank for your thanks

+ 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. VBA to Merge Cells based on Other Column Values
    By meystingray in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-19-2014, 11:10 AM
  2. Merge values from column in one cell, based on duplicates in another column
    By Rawland_Hustle in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-24-2014, 11:04 AM
  3. Running Macro with Do Loop of similar based on values in a Column
    By fishycarl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 03:50 AM
  4. How to transpose a column based on similar values
    By tdunford7 in forum Excel General
    Replies: 4
    Last Post: 02-28-2012, 12:51 AM
  5. [SOLVED] Copying cells with similar column values
    By mohd21uk via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-15-2006, 04:35 AM

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