![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 22
|
Any idea how to stop a file from closing when a before close event has been met. here is what I have so far:
Private Sub Workbook_BeforeClose(Cancel As Boolean) If ActiveSheet.Cells(85, 12).Value > 0 And ActiveSheet.Cells(85, 9).Value < 1 Then MsgBox "Enter a Travel Order Number" Else: Close End If End Sub After the MsgBox has been clicked I want the file not to close and return to the worksheet. Any help would be apreciated. Dale |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
After your message box line sitck in:
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Any idea how to stop a file from closing when a before close event has been met. here is what I have so far:
Private Sub Workbook_BeforeClose(Cancel As Boolean) If ActiveSheet.Cells(85, 12).Value > 0 And ActiveSheet.Cells(85, 9).Value < 1 Then MsgBox "Enter a Travel Order Number" cancel = true '<<<<######################### Else: Close End If End Sub After the MsgBox has been clicked I want the file not to close and return to the worksheet. Any help would be apreciated. Dale |
|
|
|
|
|
#4 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi Dale
The Cancel argument should do it. Private Sub Workbook_BeforeClose(Cancel As Boolean) If ActiveSheet.Cells(85, 12).Value > 0 And ActiveSheet.Cells(85, 9).Value < 1 Then MsgBox "Enter a Travel Order Number" Cancel = True End If End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|