Hello Dear Members!
I got file which you can review on attached, here I have two sheets.
on the second sheet I need check that total sales numbers equal each other. If they are not file can not be saved.
Actually I wrote this code. But I need this code work when I do save action on the second sheet not the first one. Vice versa when I try save any changes relate to sheet one excel doesn't allow to save.
If there is a way to solve it please help me.
![]()
Option Explicit Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim ST As Worksheet: Set ST = Worksheets("Staff Targets") With ST If ST.Range("C" & Rows.Count).End(xlUp) <> Range("B4") Then Cancel = True MsgBox "Total Staff Target Amount is not equal to Total Monthly Target!", vbCritical, "ERROR" End If End With End Sub
Bookmarks