Message box

  • Thread starter Thread starter K1KKKA
  • Start date Start date
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??????
 
Hi Kikk ka
Try this:

sub askmsg()
if msgbox("Some message", vbYesNo)=vbNo then
activeworkbook.close true
end if
end sub
 
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
 
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
 

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