Hi,
How can I edit this code to repeat the check on the next row? I would like the code to check ranges B3:B9, B12:B18, B21:B27, B30:B36, L3:L9 before closing to ensure that the user cannot close the form before editing all cells.
I should note that usually only one row will be completed at a time before closing.
Thanks!
How can I edit this code to repeat the check on the next row? I would like the code to check ranges B3:B9, B12:B18, B21:B27, B30:B36, L3:L9 before closing to ensure that the user cannot close the form before editing all cells.
I should note that usually only one row will be completed at a time before closing.
Thanks!
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ActiveSheet.Range("B3") <> "" And _
ActiveSheet.Range("C3") = "" And _
ActiveSheet.Range("D3") = "" And _
ActiveSheet.Range("E3") = "" And _
ActiveSheet.Range("F3") = "" And _
ActiveSheet.Range("G3") = "" And _
ActiveSheet.Range("H3") = "" Then
Cancel = True
MsgBox "All cells must be completed"
Else
ActiveWorkbook.Close SaveChanges:=True
End If
End Sub