I have managed to create a macro that prevents saving of a workbook if certain cells are not populated, I get a nice polite message prompting the user to return and complete the form, however, when criteria have been met and I press the button to run the macro again nothing happens. Do I need some sort of reset?
Sub Macro2()
' Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
' Macro2 Macro
' Checks number of "Fails" against number of "Details of Issue/Finding Identified" and if mismatch stop save
If Worksheets("MSAC").Range("g38") < Worksheets("MSAC").Range("f37") Then
Cancel = True
MsgBox "You cannot save until. All required 'Details of Issue / Finding Identified' cells are completed", vbOKOnly
End If
' Checks number of "Fails" against number of "Action Required to Remediate" and if mismatch stop save
If Worksheets("MSAC").Range("h38") < Worksheets("MSAC").Range("f37") Then
Cancel = True
MsgBox "You cannot save until. All required 'Action Required to Remediate' cells are completed", vbOKOnly
End If
' Checks number of "Fails" against number of "Remediation Due Date" and if mismatch stop save
If Worksheets("MSAC").Range("i38") < Worksheets("MSAC").Range("f37") Then
Cancel = True
MsgBox "You cannot save until. All required 'Remediation Due Date' cells are completed", vbOKOnly
End If
' Check completion before progress to Save & Send
Dim c As Range
For Each c In Range("J38")
If c.Value = 0 Then Exit Sub
Next c
Sub Macro2()
' Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
' Macro2 Macro
' Checks number of "Fails" against number of "Details of Issue/Finding Identified" and if mismatch stop save
If Worksheets("MSAC").Range("g38") < Worksheets("MSAC").Range("f37") Then
Cancel = True
MsgBox "You cannot save until. All required 'Details of Issue / Finding Identified' cells are completed", vbOKOnly
End If
' Checks number of "Fails" against number of "Action Required to Remediate" and if mismatch stop save
If Worksheets("MSAC").Range("h38") < Worksheets("MSAC").Range("f37") Then
Cancel = True
MsgBox "You cannot save until. All required 'Action Required to Remediate' cells are completed", vbOKOnly
End If
' Checks number of "Fails" against number of "Remediation Due Date" and if mismatch stop save
If Worksheets("MSAC").Range("i38") < Worksheets("MSAC").Range("f37") Then
Cancel = True
MsgBox "You cannot save until. All required 'Remediation Due Date' cells are completed", vbOKOnly
End If
' Check completion before progress to Save & Send
Dim c As Range
For Each c In Range("J38")
If c.Value = 0 Then Exit Sub
Next c