Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add confirmation dialog to Excel Macro

Status
Not open for further replies.

maxxheight

IS-IT--Management
Jun 17, 2004
43
0
0
US
I have a spreadsheet that contains about 300 cells that are filled up during the course of the month with daily data. At the end of the month, all of the daily entries need to be cleared out so that the sheet can then be used for a new month. I recorded a Macro to clear all of the cells that needed to be cleared, and then added a button to the spreadsheet that the end users can press which then clears out all of the data.

I have had a couple of users hit the button accidentally and erase data that was not supposed to be erased. I was wondering if anyone knew how to add a confirmation dialog to an Excel, something that would pop up an "Are you sure" box that would need to be confirmed before all of the data actually is erased.

If anyone can help I would appreciate it.

Mark J. Sheffield
America's PowerSports
 
Something like this
Code:
Sub warning()
a$ = MsgBox("Are you sure you want to delete data?", vbYesNo)
If a$ = vbYes Then
  Delete Data here
Else
  End
End If
End Sub
 
Thanks a million. That sent me in the right direction.

Have a great weekend.

Mark J. Sheffield
America's PowerSports
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top