+ Reply to Thread
Results 1 to 8 of 8

How to deal with merged cells in this case?

  1. #1
    Registered User
    Join Date
    03-22-2017
    Location
    Schiphol
    MS-Off Ver
    MS Office Professional Plus 2010
    Posts
    3

    How to deal with merged cells in this case?

    Hi all
    I have no experience whatsovever with VBA, other than copy & paste existing code and adapt it a little through lots of googling... However I run into a problem now I cannot solve.
    I want to keep track of changes in an excel document, so I use below code. Works fine, except when it has to deal with merged cells. Changes in a single cell are shown as "was changed from" OldVal "to" NewVal. But in case of a merged cell OldVal is never shown, hence I cannot see it was changed and the new input, but not the previous value in the merged cell.
    Anyone knows how to deal with this (and please consider me as a simpleton VBA wise)

    Thanks a lot!

    Please Login or Register  to view this content.
    Last edited by KNTom; 03-22-2017 at 10:20 AM. Reason: Forgot the code tags

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: How to deal with merged cells in this case?

    Merged cells are just like shared workbooks - perhaps they're a good theoretical idea but the implementation of that theory left a lot to be desired. The usual advice is not to use merged cells and I can't think of any good reason to do so.

    At the risk of being contentious, I'd suggest you redesign the workbook to avoid them. It'll get you over this issue and who knows what problems it'll prevent in the future.


    PS:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: How to deal with merged cells in this case?

    I agree with cytop. Merged cells can wreak havoc on a spreadsheet, especially when using code and/or formulas. It's best to stay away from them at all times if possible.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  4. #4
    Registered User
    Join Date
    03-22-2017
    Location
    Schiphol
    MS-Off Ver
    MS Office Professional Plus 2010
    Posts
    3

    Re: How to deal with merged cells in this case?

    Apologies; code tags were forgotten. Edited.

    But yeah, I share your notion on merged cells, but my colleagues before me not apparantly. I am stuck with it, since it is too time consuming to rebuild hundreds of files to a new design

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: How to deal with merged cells in this case?

    One reason why OldVal does not contain a value for merged cells...
    Please Login or Register  to view this content.
    A merged cell will return the number of merged cells... Again, not a solution but a pointer.

  6. #6
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: How to deal with merged cells in this case?

    Found the following VBA code made by a Rick Rochstein in comments at: http://blog.contextures.com/archives...e-excel-cells/

    Please Login or Register  to view this content.
    What it does is convert any Merged&Centered cells to UnMerged&CenteredAcrossSelection. It skips any Merged Cells that are NOT Centered.
    Maybe it can help in fixing your past colleagues' workbooks?

  7. #7
    Registered User
    Join Date
    03-22-2017
    Location
    Schiphol
    MS-Off Ver
    MS Office Professional Plus 2010
    Posts
    3

    Re: How to deal with merged cells in this case?

    Thanks for pointing out. But of course, most if not all merged cells are NOT centered

    I guess I have to lock myself up for some weeks and redesign all workbooks

  8. #8
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: How to deal with merged cells in this case?

    That sucks

    Also at that link I gave, there should be some instructions/code on how to UnMerge all cells at once, but you wouldn't be here if that was all that was needed. Wish you luck in your efforts to clean things up.

+ 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. [SOLVED] How to deal with MERGED CELL
    By Cheezee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2015, 10:37 AM
  2. Replies: 5
    Last Post: 10-28-2015, 02:36 AM
  3. Replies: 0
    Last Post: 11-25-2014, 07:08 AM
  4. automatically fit an image into merged cells for full width of merged cells
    By Marcin4111 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-18-2014, 03:12 PM
  5. Replies: 1
    Last Post: 06-28-2012, 11:53 AM
  6. Request help with Case Statement and Merged Cells
    By kys2000 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-05-2007, 06:18 PM
  7. how do i link merged cells to a merged cell in another worksheet.
    By ibbm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2006, 06:45 PM

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