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!
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

macleanb

Well-known Member
Joined
Dec 10, 2004
Messages
715
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.
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,996
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.
 

Dave.S

New Member
Joined
Feb 2, 2005
Messages
3
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.
 

Dave.S

New Member
Joined
Feb 2, 2005
Messages
3
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,126,906
Messages
5,621,577
Members
415,846
Latest member
nigeywigey

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
Top