+ Reply to Thread
Results 1 to 9 of 9

Clear Contents of cell of other cell is not equal to a value

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    Philadelphia, PA, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Clear Contents of cell of other cell is not equal to a value

    How do I clear the contents of the cell within range K3:K300 if the data in cell J is not equal to "Promotable"? Obviously, if cell J3 is not Promotable then cell K3 should be cleared, etc...

    I am not very good with VBA but tried a few things and failed.

    Thank you in advance.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Clear Contents of cell of other cell is not equal to a value

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    Philadelphia, PA, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Clear Contents of cell of other cell is not equal to a value

    Thanks AB33 but this did not work. I copied and pasted the code into the worksheet code. I changed J to Promotable and selected a value in K. When I then changed J to a value other than Promotable nothing happened to K.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Clear Contents of cell of other cell is not equal to a value

    Nothing happens because it is not event driven code. You have to put the code on standard module and run it.

  5. #5
    Registered User
    Join Date
    08-13-2012
    Location
    Philadelphia, PA, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Clear Contents of cell of other cell is not equal to a value

    Makes sense, is there a quick/easy way to make it event driven? It should run anytime column J's value is changed.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Clear Contents of cell of other cell is not equal to a value

    Put this in your worksheet

    Please Login or Register  to view this content.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Clear Contents of cell of other cell is not equal to a value

    Hi, AB33,

    if you limit the availabiiity of the macro to a cell within a range (any altering of two or more cells should raise an error) why do you call a macro that covers the whole range? I´d preferred to just have the row updated:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  8. #8
    Registered User
    Join Date
    08-13-2012
    Location
    Philadelphia, PA, USA
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Clear Contents of cell of other cell is not equal to a value

    Quote Originally Posted by HaHoBe View Post
    Hi, AB33,

    if you limit the availabiiity of the macro to a cell within a range (any altering of two or more cells should raise an error) why do you call a macro that covers the whole range? I´d preferred to just have the row updated:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    HaHoBe, thank you for assisting. Is this event driven? I need it to run anytime column J is changed.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Clear Contents of cell of other cell is not equal to a value

    Hi, steve,

    yes, it´s the event that will be triggered if any entry or change is made in the worksheet. So the code must go behind the worksheet which should be monitored (right-click on the worksheet-Tab, choose View Code, paste the code into the code-window). As any change would start the macro the range for which the code should work is narrowed down to Range J3:J300.

    Please do not quote whole posts - please feel free to have a look at the Forum Rules for further information.

    Ciao,
    Holger

+ 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