+ Reply to Thread
Results 1 to 7 of 7

Exclude column when clearing content with VBA

  1. #1
    Registered User
    Join Date
    06-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Question Exclude column when clearing content with VBA

    Hi guys, I have a button on a sheet that clears content in any of the whole workbook's unlocked cell when clicked. How do I tell it to ignore any cell, locked or unlocked, in column B and column M?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Exclude column when clearing content with VBA

    newrui,

    Give this a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    06-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Exclude column when clearing content with VBA

    Hi tigeravatar, thanks for the quick reply, but this gives a 400 error (Excel doesn't give an explanation, just shows 400). Any ideas?

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Exclude column when clearing content with VBA

    newrui,

    I am unable to duplicate that error. Can you attach an example workbook that is experiencing the issue? To attach a file, click "Go Advanced" and then click the paper clip icon to open the Manage Attachments dialog.

  5. #5
    Registered User
    Join Date
    06-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Exclude column when clearing content with VBA

    Here you go. Sorry it looks a little funny, it was a big spreadsheet, had to *** out a bunch of sensitive stuff. But it's still showing the same error for me. Excel 2010 on Win 7.

    temp.xlsm

    Thanks!

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Exclude column when clearing content with VBA

    newrui,

    The problem is due to merged cells on the 'Input 1' worksheet. The macro recognizes the first cell, A2, as an unlocked cell, but not the rest of its merge area. Simply unmerging those cells and then running the macro again allowed the macro to complete as expected with no errors.

    Generally speaking, try to avoid using merged cells at all times. There is a cell format (Center Across Selection) that does basically the same thing without merging the cells, so its highly encouraged to use that instead of merging cells.

    If those cells must be merged, let me know and I'll try to come up with a workaround

  7. #7
    Registered User
    Join Date
    06-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Exclude column when clearing content with VBA

    Works! You sir are a rock star. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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