Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find first row where condition is true? WhatsUp31415 Excel Discussion (Misc queries) 6 May 21st 09 12:11 PM
Hide Rows If Condition True wilbursj Excel Worksheet Functions 2 April 20th 09 08:09 PM
result if a condition is NOT true? Roland Excel Worksheet Functions 2 March 7th 07 09:25 AM
TRUE condition??? pmguerra Excel Discussion (Misc queries) 2 June 5th 06 04:27 PM
How Do I Hide A Row (if a condition is true) using a Macro ? Anthony Fantone Excel Worksheet Functions 1 June 16th 05 04:54 PM


All times are GMT +1. The time now is 12:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"