Erasing the contents of a range of cells within a function

Dave.S

New Member
Joined
Feb 2, 2005
Messages
3
Thank you in advance for any assistance that may be offered! I rarely use macros and have never played with Visual Basic, so please be patient with my ignorance!

Has anybody ever erased the contents of a small range of cells from within another function such as an "IF" statement? I thought this would be easyl, but has turned out not to be. To my dismay, I found out you can't run a macro from within a function either (which would have made the problem trivial!).

Any assistance is greatly appreciated!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Yep - worksheet is strictly off limits when you are being called from the worksheet - I havent had to do this - but using ontime might be a possible solution.
 
Upvote 0
Dave:

Do you have to "erase" them? Or could you just format them to have a white font so they don't show up on the screen/printed page.

If it's the later, you could conditionally format the cells you'd like to hide based on the resultant of your if statement.
 
Upvote 0
Re: Erasing the contents of a range of cells within a functi

Unfortunately, I actually need to erase (instead of hide) the contents, since the text in these cells is also being used for other calculations.
 
Upvote 0
Just wanted to update my question---thanks to a couple other folks who suggested the following solution:

Since I was unable to have the macro run directly from within an IF..THEN statement in the worksheet, it was suggested to use a checkbox control, then insert the clear-cells command within that sturucture. Worked great. Thanks to all again!
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top