add a warning before running a macro

P

Picman

i have recorded a macro that clears the contents of the unprotected unlock
cells. i would like to have a message asking if the user is sure that they
want to clear the contents or not to. is this possible?
 
D

Dave Peterson

Option Explicit
Sub YourMacHere()
Dim resp as long
resp = msgbox(prompt:="Are you sure?", buttons:=vbyesno)
if resp = vbno then
exit sub
end if

'rest of your code
End Sub
 
P

Picman

thanks Dave, sorry i'm not all that experienced with these kinds of
modifications, how would i implement your code?
 
D

Dave Peterson

You have existing code for your macro, right?

You'd copy the guts that I wrote and paste it into your procedure--right near
the top, before anything really important.

Are the only lines you'd want to paste (without those > > symbols, of course).
 
P

Picman

That worked perfectly, thanks very much

Dave Peterson said:
You have existing code for your macro, right?

You'd copy the guts that I wrote and paste it into your procedure--right near
the top, before anything really important.


Are the only lines you'd want to paste (without those > > symbols, of course).
 
Top