+ Reply to Thread
Results 1 to 11 of 11

Need to merge variable number of cells into one single cell based on criteria

  1. #1
    Registered User
    Join Date
    09-19-2009
    Location
    MN, US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Need to merge variable number of cells into one single cell based on criteria

    Here’s an example of my data:
    A B
    1 110 AAAAAAA
    2 220 BBBBBBBB
    3 330 CCCCCCCC
    4 330 DDDDDDD
    5 330 EEEEEEEEE
    6 440 FFFFFFFFF
    7 440 GGGGGGG
    8 550 HHHHHHH

    I need your help to figure out how to merge the above data to look like this in new blank worksheet using a VBA macro:
    A B
    1 110 AAAAAAA
    2 220 BBBBBBBB
    3 330 CCCCCCCC
    DDDDDDD
    EEEEEEEE
    4 440 FFFFFFFFF
    GGGGGGG
    5 550 HHHHHHH

    Thanks for your help in advance.
    Attached Files Attached Files
    Last edited by NewYorkVanilla; 09-20-2009 at 11:08 AM.

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Need to merge variable number of cells into one single cell based on criteria

    Hi, Data assumed in "A & B", Results start "F1"
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Registered User
    Join Date
    09-19-2009
    Location
    MN, US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Need to merge variable number of cells into one single cell based on criteria

    Hi Mick,

    Thank you very much for the fast response. I copy/pasted the code into a macro and tried to run it. I received the following error "runtime error '13' type mismatch. I haven't got a clue on how to fix it. Can you help?

    NewYorkVanilla

  4. #4
    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: Need to merge variable number of cells into one single cell based on criteria

    Hello NewYorkVanilla,

    On which statement or line does the error occur?
    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!)

  5. #5
    Registered User
    Join Date
    09-19-2009
    Location
    MN, US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Need to merge variable number of cells into one single cell based on criteria

    Hi -
    Please Login or Register  to view this content.
    Thanks for your help.
    Last edited by royUK; 09-20-2009 at 04:24 AM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Need to merge variable number of cells into one single cell based on criteria

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I will add them this time
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Need to merge variable number of cells into one single cell based on criteria

    Hi, I canot duplicate your error, Have you try running the code on Just your thread Data.
    Regards Mick

  8. #8
    Registered User
    Join Date
    09-19-2009
    Location
    MN, US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Need to merge variable number of cells into one single cell based on criteria

    Could this error be due to the fact that I'm using excel 2007? Thanks.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Need to merge variable number of cells into one single cell based on criteria

    Excel version should not affect this code, it seems to work in 2007

  10. #10
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Need to merge variable number of cells into one single cell based on criteria

    If you can't get that to work try an alternative!!
    Results start "H1".
    Please Login or Register  to view this content.
    Regards Mick

  11. #11
    Registered User
    Join Date
    09-19-2009
    Location
    MN, US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Need to merge variable number of cells into one single cell based on criteria

    Mick - You are fantastic! This code runs beautifully. You totally rule! Thank you so very much for helping me.

+ 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