Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a straightforward msgBox that starts when a worksheet is opened. It has vbYesNo Is there any code that I can put into or assign to the No buton that will close the worksheet without saving anything, including the prompt for 'Do you want to Save Changes' msg that normally comes up when closing. Bottom line...if Yes, then we continue with input....if No then close (exit) immediately Thanks Craig |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() The following code will open a Msgbox and if the user chooses No, the workbook will close without saving any changes. Dim Res As VbMsgBoxResult Res = MsgBox("Your Message", vbYesNo) If Res = vbNo Then ThisWorkbook.Close savechanges:=False End If Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Thu, 4 Feb 2010 13:18:05 -0800, Craig wrote: Hi, I have a straightforward msgBox that starts when a worksheet is opened. It has vbYesNo Is there any code that I can put into or assign to the No buton that will close the worksheet without saving anything, including the prompt for 'Do you want to Save Changes' msg that normally comes up when closing. Bottom line...if Yes, then we continue with input....if No then close (exit) immediately Thanks Craig |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Chip....perfect result
"Chip Pearson" wrote: The following code will open a Msgbox and if the user chooses No, the workbook will close without saving any changes. Dim Res As VbMsgBoxResult Res = MsgBox("Your Message", vbYesNo) If Res = vbNo Then ThisWorkbook.Close savechanges:=False End If Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Thu, 4 Feb 2010 13:18:05 -0800, Craig wrote: Hi, I have a straightforward msgBox that starts when a worksheet is opened. It has vbYesNo Is there any code that I can put into or assign to the No buton that will close the worksheet without saving anything, including the prompt for 'Do you want to Save Changes' msg that normally comes up when closing. Bottom line...if Yes, then we continue with input....if No then close (exit) immediately Thanks Craig . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Repeating a Macro For Each Selected Worksheet | Excel Worksheet Functions | |||
[Fwd: Run macro on exit worksheet/workbook] | Excel Discussion (Misc queries) | |||
Run macro on exit worksheet/workbook | Excel Worksheet Functions | |||
How to run a macro when a worksheet is selected | Excel Worksheet Functions | |||
Automatically Run a macro when a worksheet is selected | Excel Programming |