auto save

  • Thread starter Thread starter mikey may
  • Start date Start date
M

mikey may

I have a spreadsheet, File1, that a macro opens and pulls
data to populate another file, MasterFile1, then closes
down File1 and opens File2, etc......

Upon closing File1, how do I get excel to automatically
save or not save? e.g.

when File1 is opened if Condition1 is met then the data is
pulled into MasterFile1 and then cleared from File1.
File1 is then closed and excel produces a message box
asking if I want to save.

How do I get Excel to automatically choose 'Yes'?

If Condition1 is not met then the file is just closed
down, but Excel still asks if I want to save. In this
instance I don't want to save File1.
 
It sounds as if Condition1 is a True/False (boolean).

If so then you can use it to control whether the workbook is saved or not,
like this:

ActiveWorkbook.Close Condition1


Or your routine can be a little more explicit:

Sub a()
Dim Condition1 As Boolean
Condition1 = True ''or False, set before running this
If Condition1 Then
GetDataRoutine
ClearDataRoutine
ActiveWorkbook.Close True
Else
ActiveWorkbook.Close False
End If
End Sub
 
Back
Top