View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Don't save if cells are blank

Paste the code below in the ThisWorkbook code module. It will not allow a
save operation if Sheet1!A1 is blank.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheet1.Range("A1").Value = "" Then
MsgBox "Sheet1!A1 is blank. Save operation not allowed."
Cancel = True
End If
End Sub


--
Hope that helps.

Vergel Adriano


"MasterChief" wrote:

Does anybody have an example of VBA code that looks at certain cells
when a person clicks Save or Save as and if the cell is blank it will
display a message and not allow a save? Any help would be greatly
appreciated.