+ Reply to Thread
Results 1 to 16 of 16

Clear Cell Content on onother sheet

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Clear Cell Content on onother sheet

    Hi,

    I have two sheets. I would like to clear the content in a specific cell range on a specific sheet. I am using the following:

    shDest.Range("A5:B6").ClearContents

    whereDim shDest As Worksheet
    Set shDest = ThisWorkbook.Sheets("Filtered Data")

    This seems a simple thing to do but it does not work. Can anyone suggest a way to clear the cells of content? Thank you.

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Clear Cell Content on onother sheet

    something like this
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Clear Cell Content on onother sheet

    Thanks John but this is almost the same as I have except for the range specified. As a point of interest, I tried changing my range to "A5:A6" as a test and the code still did not work.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Clear Cell Content on onother sheet

    there's nothing wrong with the code-are you sure it's being run? do you have any error handlers that might be suppressing an error message?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Clear Cell Content on onother sheet

    if you are in sheet1 and insert a button, then add the code on it, you'll see that it works.
    Please Login or Register  to view this content.
    thx JP
    Last edited by john55; 05-08-2013 at 11:10 AM.

  6. #6
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Clear Cell Content on onother sheet

    There are no error handlers and the code subsequent to this piece executes.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Clear Cell Content on onother sheet

    How does it not work?

    Doesn't clear the specified cells?

    Errors?
    If posting code please use code tags, see here.

  8. #8
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Clear Cell Content on onother sheet

    In cells A5 and A6 I have text that does not get cleared. In cells B5 and B6 are numbers that do not get cleared. The code after this piece determines what needs to be written into those cells but the cells need to be cleared first and are not; i.e. the previous text and numbers remain after the execution of this code.

  9. #9
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Clear Cell Content on onother sheet

    see if it helps you
    Attached Files Attached Files

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Clear Cell Content on onother sheet

    You have code that clears the cells then puts values in them, but neither works.

    That's suggests that the code isn't actually being executed, perhaps you should post the rest of the code?

  11. #11
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Clear Cell Content on onother sheet

    That is not entirely correct Norie. The code subsequent to this piece works just fine and does in fact post correctly to those cells. The piece that does not work is the clearing of the cells.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Clear Cell Content on onother sheet

    Just because later code executes doesn't mean the code before was executed.

    Hard to tell though without seeing the rest of the code.

  13. #13
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Clear Cell Content on onother sheet

    Good point Norie. So the question then becomes, what would prevent that lin eof code from executing?

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Clear Cell Content on onother sheet

    Who knows without seeing the rest of the code?

  15. #15
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Clear Cell Content on onother sheet

    Fair enough. Unfortunately cannot send the code as it is proprietary. I will try to debug it. Thank you.

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Clear Cell Content on onother sheet

    We probably don't need to see it all, just the part leading up to the line(s) that don't appear to be working.

    You can expunge any sensitive data.

    PS If you do post the code please use code tags.

+ 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