Don't save file if condition is met
I don't think it's the code.
If you build a smaller workbook with just enough data to get through your code,
does it work ok?
(Just a guess.)
Andre Croteau wrote:
In both instances of trying the solutions of Steve and Dave, it caused Excel
to crash, as it did with my original solution.
In Steve's case, it first closed that specific file without saving it, but
the macro saved the second file that was opened. Then it crashed! "Excel
encountered a problem and must close"
In Dave's example, the message came up "Excel encountered a problem and must
close"
I am at a loss...
"Andre Croteau" wrote in message
...
Hello,
I have tried this macro to disable the save function if the cell A1
contains the value 1 when the user wants to save the file
I want the file to close without asking if the user any questions, but
there seems to be a coding error.
Can anyone help please?
PS I imagine I should also use the same code for the event "Private Sub
Workbook_BeforeClose"?
Thank you in advance
André
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Worksheets("Start").Cells(1, 1) = 1 Then
MsgBox "You have already Eliminated Rows! THIS FILE WILL NOT SAVE!"
ActiveWorkbook.Close = False
End If
End Sub
In ELIMINATE ROWS MACRO:
Worksheets("Start").Cells(1,1).Value = 1
--
Dave Peterson
|