View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Save If Condition is true

With this code in the ThisWorkbook module (using Excel 2000)
You can add or change the criteria.

Caution: my criteria will accept a space in the cell.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Len(Worksheets("Sheet1").Range("A1")) = 0 Then
MsgBox "Workbook cannot be saved"
Cancel = True
End If
End Sub

--
steveB

Remove "AYN" from email to respond
"igorek" wrote in message
...
I would like the user to be able to save the file only if the cell A1 is
not
empty, else do not save it, and display message "Cannot save"....

Thanks for your help