Each of the worksheets in my model use A1 as a control cell for any errors and inconsistencies. My aim is to disable save and close commands in case A1 is not equal to 0 in any of the worksheets.
The code I currently use for that purpose is as follows.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Rng As Range
Dim ws As Worksheet
For Each ws In Worksheets
Set Rng = ws.Range("A1")
If ws.Range > 0 Then
Cancel = True
lReply = MsgBox("Please correct...", vbOKOnly)
End If
End Sub
Something however is not OK and it gives errors. Furthermore, the disabling of close command is not covered.
Please help me update it.
Bookmarks