Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Saved ungrouped cells to a text file | Excel Discussion (Misc queries) | |||
Excel file opened as read-only, if saved by another user | Excel Discussion (Misc queries) | |||
How do you open a template at startup? | Excel Discussion (Misc queries) | |||
F7 in zip field when doing mail merge from excell file | Excel Discussion (Misc queries) | |||
how to undo saved file in excel | Excel Discussion (Misc queries) |