View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Adam Harding Adam Harding is offline
external usenet poster
 
Posts: 9
Default Conditional Closing and Saving

Tried all of your suggestions and they don't alter the behaviour of hte form?

Any ideas?

"Norman Jones" wrote:

Hi Adam,

In the workbook's ThisWorkbook module (not in a standard module) paste
something like:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Sheets(1).Range("A1").Value < _
Sheets(2).Range("A1").Value Then
Cancel = True
MsgBox "Your meaage to user"
End If
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If Sheets(1).Range("A1").Value < _
Sheets(2).Range("A1").Value Then
Cancel = True
MsgBox "Your meaage to user"
End If
End Sub

Change the condition to suit your requirements and change the msgbox to
something as inoffensively informative as possible.

---
Regards,
Norman



"Adam Harding" wrote in message
...
Am using Excel 2003. Want to stop users exiting or saving my spreadsheet
unless the total on one sheet = total on other sheet.

How can this be done?

Any help gratefully received