+ Reply to Thread
Results 1 to 13 of 13

Combining/merging multiple rows from one worksheet into one cell in another worksheet

  1. #1
    Registered User
    Join Date
    01-28-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Combining/merging multiple rows from one worksheet into one cell in another worksheet

    Hi all

    I'm trying to create a macro to merge multiple rows into one cell and display in a new worksheet.

    This seems really simple but I've tried to re-work some other examples I've found online but none seem to do exactly what I need. I'm also pretty new to VBA , so it's highly possible i've missed something.

    I need to display each set of Notes for each DonorNo in one row - with each note separated by a space.

    I've attached a sample of the data and what I need for the output. In the actually file I have around 70,000 records so the prospect manually merging the rows is horrifying.

    Does anyone have any suggestions?

    Thanks
    Attached Files Attached Files
    Last edited by badoody; 02-08-2010 at 11:45 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    Try this:
    Please Login or Register  to view this content.
    Last edited by StephenR; 01-28-2010 at 01:16 PM.

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    First sort Sheets("SAMPLE") by DonorNo ascending, then run macro

    Please Login or Register  to view this content.
    Can be polished, I posted a sort function recently that could be of use.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    My take on the same problem.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    JBeaucaire: do you know what you've done to make the font in your code different from the others?

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    I use the font and size functions in the reply console. You have to GO ADVANCED to even see those options. It's actually a pain, not an improvement in functionality over the old setups that did that for us automatically.

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    Hi Guys

    Noticed that you both elected to allow for blanks in column A
    eg
    Please Login or Register  to view this content.
    My reasoning is that there can be no blanks in col A hence sort/filter first to reveal any blanks and fix before running macro.

    Neat code JBeaucaire!

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    Thanks.

    Based on the OPs sample, blanks don't appear to be an issue, but doing an xlDown from the top of a dataset does occasionally bite you in the byte.

    I always search UP from the bottom of the worksheet. The OPs example doesn't include blanks, but at least the macro would work even if it runs into them.

    ========
    Badoody, if that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)

  9. #9
    Registered User
    Join Date
    01-28-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    Quote Originally Posted by StephenR View Post
    Try this:
    Please Login or Register  to view this content.
    ________________

    Thanks StephenR: This works on my sample but when I try it on the actual data it bombs out and I get Run-time error "13": Type mismatch and it points to the line
    Please Login or Register  to view this content.
    Any ideas?

  10. #10
    Registered User
    Join Date
    01-28-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    Quote Originally Posted by JBeaucaire View Post
    My take on the same problem.
    Please Login or Register  to view this content.
    ______________________
    JBeaucaire: I'm having trouble getting this to display anything in "DESIRED OUTPUT" worksheet. When I run it the worksheet stays blank. Any suggestions?

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    It was designed from your original sample.

    If some other sheet is failing, perhaps it is different in a way you didn't represent. If so, post it here.
    Attached Files Attached Files

  12. #12
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    I echo JBeaucaire. We can only go on what you post here.

  13. #13
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Combining/merging multiple rows from one worksheet into one cell in another works

    I have checked my earlier post #3, it also runs on the sample supplied. ...

    I have appended the file on this post.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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