Link to home
Start Free TrialLog in
Avatar of Jenkins
JenkinsFlag for United States of America

asked on

Clear contents of an Excel worksheet with a command button

I've placed a command button on my Excel worksheet.

I want to be able to clear the contents (set them to zero) of cells C3 through C10, D3 through D10 and E3 through E10 by clicking on the button.

Each of the cells is formatted as "Accounting".

However, I want to give the user the chance to opt out of clearing the contents via a VBYesNo message.

Something like "Are you sure you want to clear the contents of this worksheet?"

If the user selects Yes, I not only want the cells' contents to be cleared but for the worksheet to be saved as well.

Thank you.
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Try this.
29077831.xlsm
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is a project where a "msgbox" is created from a form that I wrote years ago. One problem you'll face is finding a vbExlamation icon or picture file.
message.zip