VBA code for Msgbox

C

Chris D

Hi,

I have the following code:
MsgBox "Calculating Takes a Moment, please wait...."

User has to press OK to proceed.
I would like to add under the existing line " please save file before
proceeding with this action, click Cancel to exit"
If the user selects "Cancel" then the sub is ended( somithing like: go to
end sub)
Can anyone give me the code?

thanks.

Chris
 
H

Harald Staff

Hi Chris

Sub demo()
Select Case MsgBox("You really reaaly should save this " & _
"before the lengthy process", vbYesNoCancel + vbInformation)
Case vbYes
ActiveWorkbook.Save
Case vbNo
'do nada
Case vbCancel
Exit Sub
End Select
MsgBox "procedure here"
End Sub


HTH. Best wishes Harald
 
J

Jim Thomlinson

If MsgBox("Calculating Takes a Moment, please wait. " & _
"Please save before continuing", vbOKCancel, "Proceed?") = vbOK Then
MsgBox "Save"
End If
 
C

Chris D

Thanks guys, this works!

regards,

Chris

Harald Staff said:
Hi Chris

Sub demo()
Select Case MsgBox("You really reaaly should save this " & _
"before the lengthy process", vbYesNoCancel + vbInformation)
Case vbYes
ActiveWorkbook.Save
Case vbNo
'do nada
Case vbCancel
Exit Sub
End Select
MsgBox "procedure here"
End Sub


HTH. Best wishes Harald
 
C

Chris D

Still 1 question: in the blue bar in the popupboxes the text " Microsoft
Excel" is mentioned. Is it possible to change this into something like " My
Toy"?

thanks.

Chris
 
R

Rick Rothstein \(MVP - VB\)

Add the optional 3rd argument (Title) to the MsgBox function call....

Select Case MsgBox("You really really should save this before " & _
"the lengthy process", vbYesNoCancel + vbInformation, "My Toy")

Rick
 

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

Top