close workbooks before opening another workbook
Hi Rob,
Try:
'=============
Private Sub Workbook_Open()
Dim WB As Workbook
For Each WB In Application.Workbooks
If WB.Name < Me.Name Then
WB.Close SaveChanges:=True 'Or False?
End If
Next WB
End Sub
'<<=============
This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module
---
Regards,
Norman
"Rob" wrote in message
...
I believe I may have asked this question before, but I can't seem to find
the
question or a response to it. Here it is: I have a large Excel Workbook
that I want to have open first before opening two other files that link to
this one. I want to write a macro that will close any open workbooks when
this one is open. I tried an IF statement but my programming skills are
limited thus far and I don't think I wrote the correct code. Will someone
please help?
|