I'm trying to create a macro that disable printing until all required fields have been filled in. I have two issues, the code does check all the cells required, but once all have been filled in it doesn't print. The second issue is that you can still print using the print button, or selecting from the file tab. The code is listed below, please help!!!
Private Sub CommandButton1_Click()
Dim rngRangeToCheckBeforePrinting As Range
Dim rngCell As Range
With ThisWorkbook.Worksheets("Voluntary - Outside Dept Sheet")
Set rngRangeToCheckBeforePrinting = Application.Union(.Range("C3"), .Range("C4"), .Range("C5"), .Range("F5"), .Range("D8"), .Range("D9"))
For Each rngCell In rngRangeToCheckBeforePrinting
If IsEmpty(rngCell) Then
Cancel = True
MsgBox "Please ensure that all fields have been entered", vbOKOnly + vbInformation, "Unable to print"
Exit For
End If
Next rngCell
End With
Set rngRangeToCheckBeforePrinting = Nothing
Set rngCell = Nothing
End Sub
Bookmarks