Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
pmms
 
Posts: n/a
Default Do not allow a file to be saved if "ERROR" is in any field

I'm using IF conditions to check certain cells for negative numbers - if
they're negative the output is "ERROR". I wanted to know if there is a way
to prevent the file from being saved if "ERROR" is in any cell in the
workbook.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Do not allow a file to be saved if "ERROR" is in any field

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Evaluate("SUMPRODUCT(--(ISERROR(" & _
ActiveSheet.UsedRange.Address & ")))") 0 Then
MsgBox "Errors in file"
Cancel = True
Exit For
End If
Next sh
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

--

HTH

RP
(remove nothere from the email address if mailing direct)


"pmms" wrote in message
...
I'm using IF conditions to check certain cells for negative numbers - if
they're negative the output is "ERROR". I wanted to know if there is a

way
to prevent the file from being saved if "ERROR" is in any cell in the
workbook.



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
Saved ungrouped cells to a text file EMarre Excel Discussion (Misc queries) 2 August 30th 05 02:19 PM
Excel file opened as read-only, if saved by another user GeEf Excel Discussion (Misc queries) 2 August 28th 05 04:29 PM
How do you open a template at startup? James Kendall Excel Discussion (Misc queries) 7 July 26th 05 07:33 PM
F7 in zip field when doing mail merge from excell file kshinn15 Excel Discussion (Misc queries) 0 April 16th 05 09:52 PM
how to undo saved file in excel Sheila Chiteji Excel Discussion (Misc queries) 5 February 12th 05 06:41 PM


All times are GMT +1. The time now is 02:21 PM.

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"