+ Reply to Thread
Results 1 to 8 of 8

Clear Cell Contents Based On Criteria

  1. #1
    Forum Contributor
    Join Date
    07-02-2012
    Location
    UK
    MS-Off Ver
    365/2008
    Posts
    152

    Clear Cell Contents Based On Criteria

    Hi

    I'm guessing the solution to my question will be VBA code so have enteerd it on this forum (hopefully it's the right place).

    Can someone please tell me how I can clear the contents of one cell on a row dependent on a specific value being entered in another cell on the same row. Example:

    Value in C1 is "Yes". If a date is entered in to cell M1 the value of C1 should be cleared.

    Thanks.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Clear Cell Contents Based On Criteria

    Hi,

    You can do it with this

    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Forum Contributor
    Join Date
    07-02-2012
    Location
    UK
    MS-Off Ver
    365/2008
    Posts
    152

    Re: Clear Cell Contents Based On Criteria

    Quote Originally Posted by Steffen Thomsen View Post
    Hi,

    You can do it with this

    Please Login or Register  to view this content.
    Thanks for your reply but I can't get this code to work. Maybe because I'm not use to VBA coding/macros in excel. Maybe you can see if I've done something wrong:

    I opened the relevant worksheet
    I then accessed the VBA Editor (Alt+f11)
    I selected "Insert User Form" > "Module"
    Then pasted your code
    Saved then closed the workbook
    Then re-opened and selected "Enable Macros" and entered data to test but the data in column "C" doens't disappear.

    Where have I gone wrong?

  4. #4
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Clear Cell Contents Based On Criteria

    This will not work in a module.

    Instead press "alt + F11" and then db-click on the sheet where the code should run, in the project overview on your left.
    Then paste the code here.

  5. #5
    Forum Contributor
    Join Date
    07-02-2012
    Location
    UK
    MS-Off Ver
    365/2008
    Posts
    152

    Re: Clear Cell Contents Based On Criteria

    Worked! Thanks very much for your help Steffen

  6. #6
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Clear Cell Contents Based On Criteria

    Your welcome, rememeber to mark the thread as solved.

  7. #7
    Forum Contributor
    Join Date
    07-02-2012
    Location
    UK
    MS-Off Ver
    365/2008
    Posts
    152

    Re: Clear Cell Contents Based On Criteria

    Just wondering, how can I have two of these instances on one worksheet?

    So C1 would already have turned blank as a date had been input into M1. But a later part of the process a “Yes” needs to go in R1 but, as soon as a date is input in Y1, I need R1 to go blank too.

    So this is two separate processes, C1 and M1 would always be completed before R1 and Y1.

    I tried just copying and pasting the same code in twice for the worksheet but got an error.

  8. #8
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Clear Cell Contents Based On Criteria

    Then add it to the same instance like this

    Please Login or Register  to view this content.

+ 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