LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default BeforeClose event help

How do I make sure a certain worksheet is completed properly before
closing Excel?

I have this code that I obtained from various postings in this
newsgroup on each worksheet:
-------

Private Sub Worksheet_Deactivate()
Const rngWeek As String = "nrmWWeek"
Const rngTotal As String = "gTotal"
Const rngLast As String = "lastDay"

prevSheet = Me.Name

On Error GoTo stoppit
Application.EnableEvents = False

If Me.Range(rngLast).Value < 0 Then
If Me.Range(rngTotal).Value < Me.Range(rngWeek).Value Then
Response = MsgBox("Please return to the T&T worksheet
and make corrections", _
vbOKOnly, "Total Hours Error")
Worksheets(prevSheet).Select
End If
End If

stoppit:
Application.EnableEvents = True

End Sub

--------

It checks if whether the value in nrmWWeek match the value in gTotal
and if it doesn't the user is prompted to make a corrections and
activates the previous active worksheet (prevSheet is Global). It
only works when the worksheet is deactivated. However, I also want to
prevent them from closing the workbook before making the corrections.
I know I need to insert 'some' code in the "ThisWorkbook" using
Workbook_BeforeClose but I have no idea how.

I attempted to modify the above and inserted it in the BeforeClose
event but failed. The code


Thank you,

 
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
BeforeClose Event JT Excel Programming 2 April 10th 07 03:52 PM
problem with beforeclose event Gordon Excel Programming 1 September 30th 04 11:21 PM
ThisWorkBook BeforeClose Event Doug Glancy Excel Programming 0 July 29th 04 12:36 AM
ThisWorkBook BeforeClose Event David Adamson[_4_] Excel Programming 0 July 29th 04 12:32 AM
Workbook_Beforeclose vs BeforeClose Event Juan Pablo González Excel Programming 3 February 2nd 04 12:17 AM


All times are GMT +1. The time now is 07:00 PM.

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

About Us

"It's about Microsoft Excel"