How to create a warning msg box?

  • Thread starter Thread starter jesZee
  • Start date Start date
J

jesZee

Hi experts,

I have a pop-up msg box that ask the user to click OK to proceed and
Cancel to stop the macro from running further. It is noted in my macro
condition under Msgbox action. Code:

MsgBox("Proceed with the queries?",1)=1

But, if I click on "Cancel", the macro will keep running - what should
I do to stop it? If I put in "StopMacro", this will stop my macro no
matter if I click OK or Cancel.

Pls help....THANK U!

J.
 
You are assigning the value of the answer (=1).
You should be listening for the (return value) answer:

Dim intReturnValue as Integer
intReturnValue = MsgBox("Proceed with the queries?", _
vbQuestion + vbYesNo, "Continue?")
'Msgbox return values: vbYes, vbNo, vbOK, vbCancel
If intReturnValue = vbYes then
'perform action here
Else
Exit sub
End If


jmonty
 
jmonty,

thanks for that code but i m very green when it comes to coding.

i m using macro design to get thru this pop-up msg - can you enlighten
me either putting the codes in the visual basic or in macro.

thanks a lot.

j.
 
Back
Top