Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim rngCell As Range, strBlanks As String
strBlanks = vbNullString
For Each rngCell In Sheet1.Range("B2:B238").Cells
If Len(Trim(rngCell.Value)) > 0 Then
If WorksheetFunction.CountA(rngCell.Offset(0, 2).Resize(1, 2)) < 2 Then
strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 2).Resize(1, 2).SpecialCells(xlCellTypeBlanks).Address, "$", "")
End If
If rngCell.Offset(0, 5).Value = "" Then
strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 5).Address, "$", "")
End If
If WorksheetFunction.CountA(rngCell.Offset(0, 7).Resize(1, 3)) < 3 Then
strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 7).Resize(1, 3).SpecialCells(xlCellTypeBlanks).Address, "$", "")
End If
If rngCell.Offset(0, 8).Value = "Graduated" Then
If rngCell.Offset(0, 11).Value = "" Then
strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 11).Address, "$", "")
End If
End If
If rngCell.Offset(0, 8).Value = "Left without Graduation" Then
If rngCell.Offset(0, 11).Value = "" Then
strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 11).Address, "$", "")
End If
End If
If rngCell.Offset(0, 8).Value = "Graduated" Then
If rngCell.Offset(0, 14).Value = "" Then
strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 14).Address, "$", "")
End If
End If
If rngCell.Offset(0, 14).Value = "Other, specify" Then
If rngCell.Offset(0, 15).Value = "" Then
strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 15).Address, "$", "")
End If
End If
End If
Next rngCell
If Not strBlanks = vbNullString Then
MsgBox "Entries Required In Cells " & vbCrLf & vbCrLf & strBlanks
Cancel = True
Exit Sub
End If
End Sub
Bookmarks