Message box

K

K1KKKA

i would like to place a simple yes no msg box, have tried the code i
thought worked, but not having much success,

simply want a yes no button with message,

Yes msg box closes, no file saves and closes.


Any help??????
 
M

Martin Fishlock

Hi Kikk ka
Try this:

sub askmsg()
if msgbox("Some message", vbYesNo)=vbNo then
activeworkbook.close true
end if
end sub
 
A

Alan

Sub Update()
Dim Msg, Style, Title, Response
Title = "Your Message?"
Msg = "Click 'Yes' to close this message, 'No' to save the file and close "
Style = vbYesNo + vbQuestion
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then Exit Sub
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

Regards,
Alan
 
B

bony_tony

Might want to change that to;

Sub askmsg()
If MsgBox("Some message", vbYesNo) = vbNo Then
ActiveWorkbook.Close True
Else
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
End If
End Sub

If the 'Yes' is pressed on this one, it will close without saving

Tony
 
Top