PC Review


Reply
Thread Tools Rate Thread

BeforeSave event problem

 
 
azu_daioh@yahoo.com
Guest
Posts: n/a
 
      26th Jul 2007
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

 
Reply With Quote
 
 
 
 
azu_daioh@yahoo.com
Guest
Posts: n/a
 
      26th Jul 2007
Can i enter the BeforeSave even in the worksheet code? or does it has
to be in the ThisWorkbook?

If I can only use it in the "ThisWorkbook" -- how to I refer back to
the code in the worksheet?

 
Reply With Quote
 
azu_daioh@yahoo.com
Guest
Posts: n/a
 
      26th Jul 2007
Nevermind. I figured it out. For some reason whenever I post the
problem, and read my own posts, sometimes I could come up with my own
solution. Weird.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: BeforeSave Event Jacob Skaria Microsoft Excel Programming 1 16th Apr 2010 04:45 PM
How do I change a Worksheet_change event to a beforesave event? =?Utf-8?B?VHVlYW5rZXI=?= Microsoft Excel Programming 5 29th Jun 2007 03:00 PM
Code Problem in BeforeSave Event =?Utf-8?B?S2lyayBQLg==?= Microsoft Excel Programming 3 23rd Feb 2005 10:08 PM
BeforeSave event =?Utf-8?B?Q2FybCBCb3dtYW4=?= Microsoft Excel Misc 4 6th Feb 2005 12:28 PM
BeforeSave event j23 Microsoft Excel Programming 0 6th Apr 2004 11:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:02 AM.