Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
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

  #2   Report Post  
Posted to microsoft.public.excel.misc
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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement for time based data Daren Excel Worksheet Functions 13 October 22nd 06 04:19 AM
if statement based on "starts with " Todd F. Excel Worksheet Functions 4 October 19th 05 04:41 PM
Deleting rows based on IF statement simmerdown Excel Discussion (Misc queries) 1 September 9th 05 02:18 PM
IF statement based on data type Reed Excel Worksheet Functions 1 January 20th 05 02:17 PM
Conditional formatting based on if statement. kevin Excel Worksheet Functions 2 January 12th 05 03:07 AM


All times are GMT +1. The time now is 10:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"