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 BeforeSave event problem

I have this code:
-------------
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Const rngWeek As String = "nrmWWeek"
Const rngTotal As String = "gTotal"
Const rngLast As String = "lastDay"

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("The weekly total in cell G88 should
match the value in cell B1" _
, vbOKOnly, "Total Hours Error")
Cancel = True
End If
End If

stoppit:
Application.EnableEvents = True

End Sub
----------

What I want to accomplish is to display a message when the user clicks
on the "save" button when the numbers in 2 cells dont match. But for
some reason, the above code continues to save the workbook even the
values dont match. Please help.

Thank you,
Sharon

 
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
How do I change a Worksheet_change event to a beforesave event? Tueanker Excel Programming 5 June 29th 07 03:00 PM
Need help with BeforeSave event Chuck M Excel Programming 4 March 6th 07 02:15 PM
Code Problem in BeforeSave Event Kirk P. Excel Programming 3 February 23rd 05 10:08 PM
BeforeSave event Carl Bowman Excel Discussion (Misc queries) 4 February 6th 05 12:28 PM
BeforeSave event j23 Excel Programming 0 April 6th 04 11:15 AM


All times are GMT +1. The time now is 02:46 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"