Macro confirm to run

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a simpel macro that deletes data in mutiple ranges,
I have assigned this macor to a button on the sheet.
I would like to have a confirmation window or checkbox pop up befor tha
delete code runs so the user has a way to stop it if was pressed by mistake.
Is this possabel

Thanks for any Help
 
use a statement like:

If msgbox("delete data?",vbokcancel) = vbcancel then exit sub

If Ok is selected, then the macro continues to run.

Bob Flanagan
Macro Systems
144 Dewberry Drive
Hockessin, Delaware, U.S. 19707

Phone: 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
This is a fancier version of the above:

Response = MsgBox(Prompt:="This will delete the data in YOUR ROWS" & Chr(13)
& "Do you want to continue?", Buttons:=vbYesNo + vbDefaultButton2,
Title:="DELETE DATA?")
If Response = vbYes Then
YOUR MACRO
Else
SOME OTHER ACTION ' Exit Sub, Range("A1").select
End If
End Sub

You can customize the message (Prompt:="make changes here") as needed.
The Title can be changed between the "as well".
+ vbDefaultButton2 ' sets the default to NO ({Button1 defaults to YES). The
enter key or mouse clicks the default button.
Health and Happiness, Lou
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top