MSGBox based on If Statement
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 |
MSGBox based on If Statement
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 |
MSGBox based on If Statement
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 |
All times are GMT +1. The time now is 12:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com