+ Reply to Thread
Results 1 to 4 of 4

Clear cell contents if greater or less than another cell

  1. #1
    Registered User
    Join Date
    02-15-2019
    Location
    Malta
    MS-Off Ver
    2017
    Posts
    12

    Clear cell contents if greater or less than another cell

    Cannot find a VBA for the below maybe someone can please help out

    I have 2 column ranges (F11:F74) and H11:H74) filled with different numbers. In cell X10 I have a value that changes dynamically based on conditions in another sheet. What I need to achieve is to clear the contents in the above ranges (F and H) which are lower than the value in cell X10

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Clear cell contents if greater or less than another cell

    Hi,

    A macro won't react to a cell with a formula that happens to change value. You would need to attach the following macro to a button or trigger it witrh some other event procedure

    Please Login or Register  to view this content.
    Change the VBA Sheet1 code name as necessary.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Clear cell contents if greater or less than another cell

    Right Click on your sheet name at the bottom of excel and select view code

    Paste this code into the module that opens and close the module.

    This will run a macro whenever X10 is changed and will do what you want.

    However. 1. It will overwrite H11 to J74
    2. It will run whenever the spreadsheet recalculates so might slow you down.
    3. It would be better if you could specify which cell you want to change manually to trigger the macro.
    4. Run the Macro "Reset" if the Macro stops working.

    I cannot post the Macro so a sample is attached.
    Attached Files Attached Files
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Registered User
    Join Date
    02-15-2019
    Location
    Malta
    MS-Off Ver
    2017
    Posts
    12

    Re: Clear cell contents if greater or less than another cell

    Hello Richard,

    Thanks for your feedback. Seems to be working good. Is there a way I can edit it so only the values are cleared but not formatting?

    Thanks
    Charles

+ 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] Check Column for text then clear cell contents of cell if found
    By fireguy7 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2018, 12:56 PM
  2. [SOLVED] Needing VBA code to clear contents of cell when the contents of another cell is cleared
    By jeh0714 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-15-2016, 03:49 PM
  3. Clear merged cell contents in comand button(clear all)
    By mohan_984 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-25-2015, 10:39 AM
  4. VBA to clear contents of the cell in a column of data in a cell starts with specific word.
    By winmaxservices1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2015, 08:25 AM
  5. [SOLVED] move down column and for every blank cell, clear contents of cell to the left
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2014, 11:23 AM
  6. Clear contents in one cell when contents of another cell are deleted
    By rlbush2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2012, 10:29 PM
  7. Macro that will clear contents of cell based on format of text in adjacent cell
    By judasdac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2012, 01:56 AM

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