D
donfon13
I am trying to trap users from closing a spreadsheet if not all require
fields are entered. I have 4 tabs that contain required fields. Th
code below is a test to ensure that I can trap them. However, I pla
to have this code available on numerous spreadsheets but the amount o
rows for each spreadsheet may be different. Therefore, I am trying t
figure out how I can determine what the range should be and incorporat
into this code. Thanks in advance for your help
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.CountA(Worksheets("Project").Range("A2:J2")) <> 10 Then
MsgBox "required fields missing"
Cancel = True
Else
If Application.CountA(Worksheets("Schedule").Range("A22")) <> 4 Then
MsgBox "required fields missing"
Cancel = True
Else
If Application.CountA(Worksheets("Budget").Range("A2:L2")) <> 12 Then
MsgBox "required fields missing"
Cancel = True
Else
If Application.CountA(Worksheets("Resource").Range("A22")) <> 4 Then
MsgBox "required fields missing"
Cancel = True
End If
End If
End If
End If
End Su
fields are entered. I have 4 tabs that contain required fields. Th
code below is a test to ensure that I can trap them. However, I pla
to have this code available on numerous spreadsheets but the amount o
rows for each spreadsheet may be different. Therefore, I am trying t
figure out how I can determine what the range should be and incorporat
into this code. Thanks in advance for your help
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.CountA(Worksheets("Project").Range("A2:J2")) <> 10 Then
MsgBox "required fields missing"
Cancel = True
Else
If Application.CountA(Worksheets("Schedule").Range("A22")) <> 4 Then
MsgBox "required fields missing"
Cancel = True
Else
If Application.CountA(Worksheets("Budget").Range("A2:L2")) <> 12 Then
MsgBox "required fields missing"
Cancel = True
Else
If Application.CountA(Worksheets("Resource").Range("A22")) <> 4 Then
MsgBox "required fields missing"
Cancel = True
End If
End If
End If
End If
End Su