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