Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I currently have a WorkbookBeforeClose routine to run that will prevent
closing a workbook if a cell value = "no". The user wants to be able to have a message box pop up that will allow them to close if they press "Yes" and disregard the WorkbookBeforeClose routine or to go to cell U105 as per the routine listed below. Can anyone help me to accomplish both of these options. Also, can I use a name range instead of U105? Private Sub Workbook_BeforeClose(Cancel As Boolean) If Worksheets("DIOU Stats").Range("x2").Value = "no" Then Application.Goto Worksheets("DIOU Stats").Range("u105") Cancel = True End If End Sub |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Msgbox("Close the file?", vbYesNo) = vbNo Then Application.Goto Worksheets("DIOU Stats").Range("named_range") Cancel = True End If End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Tony" wrote in message ... I currently have a WorkbookBeforeClose routine to run that will prevent closing a workbook if a cell value = "no". The user wants to be able to have a message box pop up that will allow them to close if they press "Yes" and disregard the WorkbookBeforeClose routine or to go to cell U105 as per the routine listed below. Can anyone help me to accomplish both of these options. Also, can I use a name range instead of U105? Private Sub Workbook_BeforeClose(Cancel As Boolean) If Worksheets("DIOU Stats").Range("x2").Value = "no" Then Application.Goto Worksheets("DIOU Stats").Range("u105") Cancel = True End If End Sub |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If Worksheets("DIOU Stats").Range("x2").Value = "no" Then
If MsgBox ("Close Anyhow?",vbyesno,"Options") < vbNo Then Application.Goto Worksheets("DIOU Stats").Range("u105") Cancel = True End If End If program will see the "no" value and then will ask if they wish to close anyhow, rather than doing previous cancel. But if they say "Yes (close anyhow)" it will skip the cancelling routine and just close the workbook. "Tony" wrote: I currently have a WorkbookBeforeClose routine to run that will prevent closing a workbook if a cell value = "no". The user wants to be able to have a message box pop up that will allow them to close if they press "Yes" and disregard the WorkbookBeforeClose routine or to go to cell U105 as per the routine listed below. Can anyone help me to accomplish both of these options. Also, can I use a name range instead of U105? Private Sub Workbook_BeforeClose(Cancel As Boolean) If Worksheets("DIOU Stats").Range("x2").Value = "no" Then Application.Goto Worksheets("DIOU Stats").Range("u105") Cancel = True End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF statement for time based data | Excel Worksheet Functions | |||
if statement based on "starts with " | Excel Worksheet Functions | |||
Deleting rows based on IF statement | Excel Discussion (Misc queries) | |||
IF statement based on data type | Excel Worksheet Functions | |||
Conditional formatting based on if statement. | Excel Worksheet Functions |