VBA to be applied to two sheets

Hello,

I'm hoping that someone can help me. I have a form which has a mandatory cell which needs to be completed before saving (Cell G9).
The workbook has two sheets to it "Day Shift" and "Night Shift"

I am using the following VBA Code, which works for "Day Shift". How do I get it to also work on "Night Shift"?

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim cell As Range
For Each cell In Worksheets("Day Shift").Range("G9")
If IsEmpty(cell.Value) Then
MsgBox "You must fill in Pre-rig/Load In Status " & cell.Address
Application.Goto cell
Cancel = True
Exit For
End If
Next cell
End Sub

Many thanks

Mike

Nick's picture

Private Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim cell As Range
For Each cell In Worksheets("Day Shift").Range("G9")
If IsEmpty(cell.Value) Then
MsgBox "You must fill in Pre-rig/Load In Status " & cell.Address
Application.Goto cell
Cancel = True
Exit For
End If
Next cell

' add this
'#############################
For Each cell In Worksheets("Night Shift").Range("G9") 'you might need to change the "G9" bit
If IsEmpty(cell.Value) Then
MsgBox "You must fill in Pre-rig/Load In Status " & cell.Address
Application.Goto cell
Cancel = True
Exit For
End If
Next cell
'#############################

End Sub