Could anyone expand on this a bit?
If input is entered into column C (range C2:C100), then row cells for columns D, E ,F, H or I must NOT be blank upon save.
Could be that one or more of these row cells are left blank by mistake.
An error msg pops up upon attempt to save and colors each cell yellow that lacks info.
I found this coding in another thread.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim rngCell1 As Range
Dim rngCell2 As Range
Dim strSheet As String
Dim varResponse As Variant
Cancel = False
'set cells to check:
strSheet = "Sheet1" 'name of the sheet you want to check.
varResponse = Empty
rngCell1 = Worksheets(strSheet).Range("A2")
rngCell2 = Worksheets(strSheet).Range("B3")
If rngCell1.Value = Empty Then
varResponse = MsgBox("You must enter a value in cell " & rngCell1.Address, vbCritical + vbOKOnly)
Sheets(strSheet).rngCell1.Select
ElseIf rngCell2.Value = Empty Then
varResponse = MsgBox("You must enter a value in cell " & rngCell2.Address, vbCritical + vbOKOnly)
Sheets(strSheet).rngCell2.Select
Else
'continue code here ..
GoTo CompleteExit
End If
Cancel = True
CompleteExit:
Cancel = False
End Sub
Bookmarks