Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have folowing code
Private Sub Workbook_BeforeClose(Cancel As Boolean) If Range("G2").Value = "UNBALANCED!" Then Response = MsgBox("ATTENTION UNBALANCED! Yes to go ahead / No to Cancel and correct.", vbYesNo) If Rensponse = vbNo Then Exit Sub If Response = vbYes Then End if End Sub What I want to achieve is: when pressed "No" to go back to sheet, to stop closing procedure When pressed "Yes" close workbook Is this possible? Cheers, Harold |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi harold
basically this structure should help you ------------------------------------------------------------- Private Sub Workbook_BeforeClose(Cancel As Boolean) If MsgBox("bla", vbYesNo) = vbNo Then Cancel = True End If End Sub ------------------------------------------------------------ just change the msgbox to your wishes. hth Carlo |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Sub Workbook_BeforeClose(Cancel As Boolean)
With ActiveWorkbook If Sheets("Sheet1").Range("G2").Value = "Unbalanced" Then msg = "ATTENTION UNBALANCED! Do You Want Save Changes? Yes to Save. " msg = msg & "No to Cancel and Correct." ans = MsgBox(msg, vbQuestion + vbYesNo) Select Case ans Case vbYes Me.Save Case vbNo Cancel = True Exit Sub End Select End If End With End Sub Gord Dibben MS Excel MVP On Tue, 20 Nov 2007 16:32:46 -0800 (PST), mohavv wrote: I have folowing code Private Sub Workbook_BeforeClose(Cancel As Boolean) If Range("G2").Value = "UNBALANCED!" Then Response = MsgBox("ATTENTION UNBALANCED! Yes to go ahead / No to Cancel and correct.", vbYesNo) If Rensponse = vbNo Then Exit Sub If Response = vbYes Then End if End Sub What I want to achieve is: when pressed "No" to go back to sheet, to stop closing procedure When pressed "Yes" close workbook Is this possible? Cheers, Harold |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
close a workbook after 5 minutes | Excel Discussion (Misc queries) | |||
Close personal projekt workbook | Excel Discussion (Misc queries) | |||
run macro on workbook close | Excel Discussion (Misc queries) | |||
close only one workbook | New Users to Excel | |||
How can I close only 1 workbook when I have many open? | Excel Discussion (Misc queries) |