+ Reply to Thread
Results 1 to 17 of 17

Clearing Contents Below Merged Cells

  1. #1
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Clearing Contents Below Merged Cells

    I have some code that worked perfectly until I added a logo with merged cells above the data. Now I get a message about not working with merged cells. I changed the reference to point to the cells below the merged cells but it still does not work.


    Please Login or Register  to view this content.

    The bold line above -- .Parent.Columns(1).ClearContents -- seems to be the problem; it sees the merged cells above and fails.

    I want to clearContents but only from row 8 and down in column A.

    Your suggestions would be most appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Hi,

    Could you please upload your workbook so that I may debug the code in context.

    Thanks

  3. #3
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Clearing Contents Below Merged Cells

    I have attached a sample; the actual workbook is huge. Please let me know if example is not sufficient. Thanks.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Sorry to be unclear, but I will need to see the code in action, so I will need a desensitized copy of your actual workbook so that I can run the macro and debug it.

    Let me know if you have any more questions

  5. #5
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Clearing Contents Below Merged Cells

    All i want to do is change that one line of code so that it clears contents below the merged cells. If another file is essential for this let me know.

  6. #6
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Sorry if I am being a pain here, but I will need the actual workbook. I just tried testing the line with the error and it goes off without a problem. And I can't implement your entire code as I don't know what values are on the "Assignments" worksheet.

    Unfortunately, this makes it impossible to debug your code without the actual workbook

  7. #7
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Actually, I may have figured this out without your workbook...try replacing
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Let me know how this goes. I'm really just grasping at straws here.

    If this doesn't work, then please upload your workbook as previously discussed
    Last edited by ajryan88; 08-15-2013 at 09:57 PM.

  8. #8
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Clearing Contents Below Merged Cells

    Hi ajryan88,

    Thanks for the attempt. It had the same error "We can't do that to a merged cell." Guess I will need to cobble together a better sample.

    tom

  9. #9
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Thanks,

    I just need a sample that includes the "Assignments" worksheet (at least part of it), as well as some merged cells on the main worksheet in the same location as in the actual worksheet, and it must include your code in the worksheet module.

    Thanks again

  10. #10
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Actually, another random thought, but this may just overcome the merged cell problem. Replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    I think this one has a better chance of working than my last proposed code change.

    *Fingers crossed*

  11. #11
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Clearing Contents Below Merged Cells

    Hi ajryan88,

    I am attaching a workbook with macro so you can see how and where it fails. Thanks again for your help.
    Attached Files Attached Files
    Last edited by snapfade; 08-16-2013 at 12:08 PM.

  12. #12
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Thanks.

    Try this new code and tell me if it still functions correctly. The code doesn't fail, but I may not have replicated what the old code did, so please just let me know and I will be happy to make any changes that are necessary
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Clearing Contents Below Merged Cells

    It works! But it takes an awfully long time. Is it possible to somehow determine how many rows are populated from prior run and then clear only those cells?

  14. #14
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    Hi,

    It already does predetermine how many rows are populated. What is taking a long time are the calculations in the other columns of the spreadsheet. When I run the code, it populates really fast, but then Excel takes ages to calculate the spreadsheet (you can see this in the bottom-right hand corner of the status bar). To test this theory, try putting Excel into manual calculation mode (Calculation Options under the Formulas tab), and then run the macro, and then press F9 to calculate the worksheet manually. With any luck, everything goes like lightning until you press F9.

    Hope this helps

  15. #15
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Clearing Contents Below Merged Cells

    Thanks, ajryan88! The code works perfectly! Thanks again for the help. Have a super day. tom

  16. #16
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Clearing Contents Below Merged Cells

    No problems!

    Please don't forget to click on the * next to my post to say thank you

    You have a great day too

  17. #17
    Spammer
    Join Date
    06-09-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Microst Office 365 Plus
    Posts
    149

    Re: Clearing Contents Below Merged Cells

    Comments are disabled for non logged in users so I'm posting this to help people

    Answer was:

    .Parent.Columns(.MergeArea.Columns.Count).ClearContents

    If you need to just clear contents of merged cells and dont mind unmerging them

    clear_range.UnMerge
    clear_range.Clear

    should do it

+ 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] Help with Code - clearing contents of cells
    By sajanpatel15 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2013, 03:17 PM
  2. [SOLVED] Clearing contents of only blank cells
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2012, 09:35 AM
  3. Help required clearing merged, multiple cells
    By PainZ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-25-2009, 07:39 AM
  4. [SOLVED] [SOLVED] Clearing the Contents of Merged Cells
    By prizm1 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 09-10-2005, 12:05 AM
  5. [SOLVED] clearing the contents of specified cells
    By Jimmy Pop in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-26-2005, 09:05 PM

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