Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ChkRng As Range, c As Range
With Sheets("Sheet1") 'Change to the sheet of choice
Set ChkRng = .Range("A1:C10") 'Change to the range of choice
For Each c In ChkRng
If IsEmpty(c) Then
Cancel = True
Sheets("Sheet1").Select
c.Select
MsgBox ("All cells in the range " & ChkRng.Address(0, 0) & " must have an entry before saving."), , "Save cancelled"
Exit For
End If
Next c
End With
End Sub
You won't see it in your list of macros (when you press Alt+F8) becauseWhy can't I see this on my list of macros when I click Run Macro?
The only stupid questions are the ones that don't get asked. :wink:Sorry about the stupid questions.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim LstRw As Long, i As Long, c As Range
With Sheets("Sheet1") 'Change to the sheet of choice
LstRw = .Cells(Rows.Count, "L").End(xlUp).Row
For i = 11 To LstRw
If IsEmpty(.Cells(i, "M")) Or _
IsEmpty(.Cells(i, "N")) Or _
IsEmpty(.Cells(i, "P")) Then
Cancel = True
.Select
For Each c In .Range(.Cells(i, "M"), .Cells(i, "P"))
If IsEmpty(c) And Not c.Column = 15 Then
c.Select
Exit For
End If
Next
MsgBox ("All cells in the ranges" & Chr(10) & _
"M11 : N" & LstRw & " and" & Chr(10) & _
"P11 : P" & LstRw & Chr(10) & _
"must have an entry before saving."), , "Save cancelled"
Exit For
End If
Next
End With
End Sub
Dang near anything is possible.Is this possible?