+ Reply to Thread
Results 1 to 5 of 5

Merging a large group of cells in VB

  1. #1
    Registered User
    Join Date
    07-29-2008
    Location
    Anaheim
    Posts
    2

    Merging a large group of cells in VB

    Hey everyone,

    I'm very new to VB and having difficulty merging a large group of cells through a macro.

    Basically I need to merge certain cells in a specific way to uphold formatting but also able to unmerge them as Excel->Outlook->Excel copy pasting doesn't work very well.

    For example to unmerge cells I can grab a large group of them:
    Range("D3:P14,D16:P27,D29:P40,D42:P53,D55:P66").Select and then select Selection.Unmerge. Unfortunately probably due to how unrefined this is, doing this method over roughly 10 times, the code starts breaking and certain cells aren't being unmerged.

    Alternatively, I need to merge these cells back into more Specific ranges (as they started) Example:

    Range("D3:P3,D4:P5,").Select
    Selection.Merge

    Same problem, when I go more than a few lines deep, the code breaks, again because I know this is not the proper way to do this, it's mostly what I've learned through the record feature.

    Thanks for all your help with this one!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Welcome to the forum.

    I think it's safe to say that every Mod here would recommend that you not merge cells. It is a perpetual headache.

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    I second shg's motion !

  4. #4
    Registered User
    Join Date
    07-29-2008
    Location
    Anaheim
    Posts
    2
    yah I'm starting to see your point with that one. Everything I've tried works for a while then unexpectedly starts breaking.

    Guess I might have to handle it the old fashion way...

    Thanks!

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    For formatting you can also use " center across selection"
    That makes things easier

+ 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