+ Reply to Thread
Results 1 to 11 of 11

Merge cells with same content

  1. #1
    Registered User
    Join Date
    07-08-2011
    Location
    New York City
    MS-Off Ver
    Excel 2010
    Posts
    23

    Merge cells with same content

    Hello:

    I have a report in Excel where records are sorted, grouped, and separated by an empty row. I would like to merge and center cells for each group of records in columns A, B, and C since they all contain the same values per record. Other cells in the record contain different record-specific values (amounts, percents, quantities, etc).

    For example, cell A1 contains ID# (records and sorted and grouped based on this ID number), cell B1 contains name of the company, and cell C1 contains city. Since this data repeats in columns A, B, and C, I would like to merge these in a group.

    How can I do this?

    Thanks!
    Last edited by rainbowforest; 09-25-2011 at 02:56 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Merge cells with same content

    Hi rainbowforest,

    Excel works really well if your data is in a table with no blank rows or columns. See:
    http://www.excel-2010.com/tables-in-excel-2010/ or
    http://blogs.office.com/b/microsoft-...xcel-2010.aspx

    It seems by your question, you want to remove or merge the similar data or group your data so it looks like:
    You might be able to accomplish what you want by grouping your data instead of merging. See:
    http://www.lynda.com/Excel-2010-tuto...s/68238-4.html

    In general it is a bad idea to merge your cells into a single cell.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    07-08-2011
    Location
    New York City
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Merge cells with same content

    Quote Originally Posted by MarvinP View Post
    Hi rainbowforest,

    Excel works really well if your data is in a table with no blank rows or columns. See:
    http://www.excel-2010.com/tables-in-excel-2010/ or
    http://blogs.office.com/b/microsoft-...xcel-2010.aspx

    It seems by your question, you want to remove or merge the similar data or group your data so it looks like:
    You might be able to accomplish what you want by grouping your data instead of merging. See:
    http://www.lynda.com/Excel-2010-tuto...s/68238-4.html

    In general it is a bad idea to merge your cells into a single cell.
    Hello MarvinP,

    I'll take a look into the links. I know it's a bad idea to merge these cells and honestly I wouldn't do it because I don't think the report looks any better. On the contrary. But that's how the management wants it, so I just have to go by their wishes. Since this merging is the last step in the process of creating this report, I figured I might as well merge the cells since I won't need to reference it anymore. I copied/pasted all the values so hopefully merged cells won't affect this daily report.

  4. #4
    Registered User
    Join Date
    07-08-2011
    Location
    New York City
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Merge cells with same content

    All that is good, but I need to do this via VBA code. I know how to use Excel to merge cells and group, but that's now what I need in this case. I need VBA to do this automatically for me, since the rest of the report is done in VBA, not manually.

    Previously, this report was done manually which meant spending 1.5 hrs every day which is ridiculous. Now, I'm trying to make this entirely in VBA so it can be done in couple of seconds. I finished 95% of the report in code, and now this merging part is suppose to be one of the last steps.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Merge cells with same content

    hi, rainbowforest, can you post sample workbook showing original data and result you need to obtain?

  6. #6
    Registered User
    Join Date
    07-08-2011
    Location
    New York City
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Merge cells with same content

    Quote Originally Posted by watersev View Post
    hi, rainbowforest, can you post sample workbook showing original data and result you need to obtain?
    Please look at the attachment. To the left is the current look of the report (first three columns), and to the right is the desired appearance of the report.

    Thanks!
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Merge cells with same content

    hi, rainbowforest, please check attachment, run code "test"
    Attached Files Attached Files
    Last edited by watersev; 09-25-2011 at 10:48 AM.

  8. #8
    Registered User
    Join Date
    07-08-2011
    Location
    New York City
    MS-Off Ver
    Excel 2010
    Posts
    23

    Thumbs up Re: Merge cells with same content

    Thank you watersev. That worked!

  9. #9
    Registered User
    Join Date
    07-08-2011
    Location
    New York City
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Merge cells with same content

    Quote Originally Posted by watersev View Post
    hi, rainbowforest, please check attachment, run code "test"
    I forgot that I have the header row in original report and now it merges with the first record when I run this piece of code. What do I need to add in order for this code to skip the first header row? Thanks.

  10. #10
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Merge cells with same content

    hi, provided title is in row 1, change this:

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.
    or check attachment
    Attached Files Attached Files
    Last edited by watersev; 09-29-2011 at 08:24 AM.

  11. #11
    Registered User
    Join Date
    07-08-2011
    Location
    New York City
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Merge cells with same content

    Quote Originally Posted by watersev View Post
    hi, provided title is in row 1, change this:

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.
    or check attachment
    Excellent! I figured data_rng needed to be fixed but I couldn't figure out the way to do it. It works now. Thanks!

+ 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