Warning Message before a Macro is Run

  • Thread starter Thread starter amirstal
  • Start date Start date
A

amirstal

Is there a way to have a warning message pop-up before a macro is
applied (i.e., once you press the macro button, the warning will appear
and ask for a second confirmation of the process before it starts...)?

Thanks.
 
The following code will ask the user if they want to continue, and if
they choose not to, it will end the macro. This needs to be placed at
the top of the macro when you "edit" the macro. If you need help doing
that, write back.


if msgbox("Are you sure that you want to run this macro?",vbyesno, "Are
you sure?") = vbno then
exit sub
end if
 
Thanks Brian,

It did not work...
Here is how I tried:

Sub cleanblotter()
'
' cleanblotter Macro
' Macro recorded 12/11/2006 by Reuters LTD
' ifmsgbox("Are you sure that you want to clean the
blotter?",vbyesno,"Are you sure?")=vbno then
Exit Sub
End If

Range("AN19").copy
Range("AL19").PasteSpecial xlPasteValues

Range("A11:A1000,B11:B1000,D11:D1000,E11:E1000,G11:G1000,I11:I1000,J11:J1000,K11:K1000").Select
Range("I11").Activate
Selection.ClearContents
Range("A11").Select

End Sub


Amir
 
amirstal said:
Thanks Brian,

It did not work...
Here is how I tried:

Sub cleanblotter()
'
' cleanblotter Macro
' Macro recorded 12/11/2006 by Reuters LTD
' ifmsgbox("Are you sure that you want to clean the
blotter?",vbyesno,"Are you sure?")=vbno then
Exit Sub
End If

Range("AN19").copy
Range("AL19").PasteSpecial xlPasteValues

Range("A11:A1000,B11:B1000,D11:D1000,E11:E1000,G11:G1000,I11:I1000,J11:J1000,K11:K1000").Select
Range("I11").Activate
Selection.ClearContents
Range("A11").Select

End Sub


Amir
 
Sub cleanblotter()
'
' cleanblotter Macro
' Macro recorded 12/11/2006 by Reuters LTD
' If MsgBox("Are you sure that you want to clean the blotter?", _
vbyesno,"Are you sure?")=vbno then Exit Sub

Range("AN19").copy
Range("AL19").PasteSpecial xlPasteValues

Range("A11:A1000,B11:B1000,D11:D1000,E11:E1000,G11:G1000,I11:I1000,J11:J1000,K11:K1000").ClearContents
Range("A11").Select

End Sub

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
You need a space between 'if' and 'msgbox' and also the ' at the
beginning of the line comments out the line, therefoere it doesn't run.
Remove the ' at the beginning of the if statement. See below.

******************************************************
Sub cleanblotter()
'
' cleanblotter Macro
' Macro recorded 12/11/2006 by Reuters LTD
if msgbox("Are you sure that you want to clean the
blotter?",vbyesno,"Are you sure?")=vbno then
Exit Sub
End If

Range("AN19").copy
Range("AL19").PasteSpecial xlPasteValues


Range("A11:A1000,B11:B1000,D11:D1000,E11:E1000,G11:G1000,I11:I1000,J11:J100­0,K11:K1000").Select
Range("I11").Activate
Selection.ClearContents
Range("A11").Select

End Sub

**************************************************************
 
Superb!!!
Thanks very much!!

Amir

You need a space between 'if' and 'msgbox' and also the ' at the
beginning of the line comments out the line, therefoere it doesn't run.
Remove the ' at the beginning of the if statement. See below.

******************************************************
Sub cleanblotter()
'
' cleanblotter Macro
' Macro recorded 12/11/2006 by Reuters LTD
if msgbox("Are you sure that you want to clean the
blotter?",vbyesno,"Are you sure?")=vbno then
Exit Sub
End If

Range("AN19").copy
Range("AL19").PasteSpecial xlPasteValues


Range("A11:A1000,B11:B1000,D11:D1000,E11:E1000,G11:G1000,I11:I1000,J11:J100­0,K11:K1000").Select
Range("I11").Activate
Selection.ClearContents
Range("A11").Select

End Sub

**************************************************************
 

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