Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save If Condition is true
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save If Condition is true
Hi igorek,
Put the following code inthe ThisWorkbook Module: Private Sub Workbook_BeforeSave(ByVal SaveAsUI _ As Boolean, Cancel As Boolean) If IsEmpty(Worksheets("Sheet1").Range("A1")) Then Cancel = True MsgBox "Cannot save..." End If End Sub or Private Sub Workbook_BeforeSave(ByVal SaveAsUI _ As Boolean, Cancel As Boolean) Cancel = IsEmpty(Worksheets("Sheet1").Range("A1")) End Sub Regards, KL "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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to find first row where condition is true? | Excel Discussion (Misc queries) | |||
Hide Rows If Condition True | Excel Worksheet Functions | |||
result if a condition is NOT true? | Excel Worksheet Functions | |||
TRUE condition??? | Excel Discussion (Misc queries) | |||
How Do I Hide A Row (if a condition is true) using a Macro ? | Excel Worksheet Functions |