View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 1,726
Default 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