It would have been better if you told us the worksheet name those cells are on and their addresses; but since you did not do that, I'll give you code and you will have to change my guesses of "Sheet1" and cells F6, H11, K6 and K7 to match your actual setup before running the code (the values you have to change are in the Const statements)...
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim FilledCellCount As Long
Const SheetContainingtheCells As String = "Sheet2"
Const FourCellsToCheck As String = "F6,H11,K6:K7"
FilledCellCount = WorksheetFunction.CountA(Worksheets(SheetContainingtheCells).Range(FourCellsToCheck))
If FilledCellCount > 0 And FilledCellCount <> 4 Then
Cancel = True
MsgBox "Since you filled in one of the cells in the Range " & FourCellsToCheck & _
" then you must fill in the remaining cells in that range.", vbExclamation
End If
End Sub
To install this code, first press ALT+F11 to go into the VBA editor. Once there, look at the right side and locate the panel labeled "Project - VBA Project"... inside that panel are listed all your sheets and an item labeled "ThisWorkbook"... double click that item and copy/paste the above code into the code window that just opened up. That's it. If one of the cells is filled in, but not all four of them, and the user tries to close the workbook, he/she will be shown a MessageBox and then the attempt to close the workbook will be cancelled.
Bookmarks