VB msgbox exit

F

Fraggs

I've got a msgbox that asks a question, that questio
being "Do you wish to continue?" and two VB button, "yes" & "No". I
they click "yes" I want the macro to continue, if on the other han
they click "no" I want the .xls to close without saving.
Can this be done and if so how?[/FONT
 
C

Chip Pearson

Try something like

Dim Result As Long
Result = MsgBox("Do you want to continue", vbYesNo)
If Result = vbNo Then
ThisWorkbook.Close savechanges:=False
Exit Sub
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
B

Bob Phillips

If MsgBox("Do you want to continue", vbYesNo) = vbNo Then
ActiveWorkbook.Close SaveChanges:=False
Exit Sub
End If



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top