Vato,
This is an update on the code but I'm not sure I am properly understanding
what you want, as finding a dynamic last column doesn't add much
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim cLastCol As Long
Dim rng As Range
cLastCol = Cells(2, Columns.Count).End(xlToLeft).Column
With Worksheets("Project")
Set rng = .Range("A2", Cells(2, cLastCol))
End With
If Application.CountA(rng) <> 10 Then
MsgBox "required fields missing"
Cancel = True
Exit Sub
End If
cLastCol = Cells(2, Columns.Count).End(xlToLeft).Column
With Worksheets("Schedule")
Set rng = .Range("A2", Cells(2, cLastCol))
End With
If Application.CountA(rng) <> 4 Then
MsgBox "required fields missing"
Cancel = True
Exit Sub
End If
cLastCol = Cells(2, Columns.Count).End(xlToLeft).Column
With Worksheets("Budget")
Set rng = .Range("A2", Cells(2, cLastCol))
End With
If Application.CountA(rng) <> 12 Then
MsgBox "required fields missing"
Cancel = True
Exit Sub
End If
cLastCol = Cells(2, Columns.Count).End(xlToLeft).Column
With Worksheets("Resource")
Set rng = .Range("A2", Cells(2, cLastCol))
End With
If Application.CountA(rng) <> 4 Then
MsgBox "required fields missing"
Cancel = True
End If
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)