ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Code req to close all workbooks (https://www.excelbanter.com/excel-programming/340908-re-vba-code-req-close-all-workbooks.html)

Neil Atkinson

VBA Code req to close all workbooks
 
Many Thanks I had forgot how simple that is...

Rgds
Neil

*** Sent via Developersdex http://www.developersdex.com ***

Bob Phillips[_6_]

VBA Code req to close all workbooks
 
You might also want to test for Personal.xls, you probably don't want to
close that.

--
HTH

Bob Phillips

"Neil Atkinson" wrote in message
...
Many Thanks I had forgot how simple that is...

Rgds
Neil

*** Sent via Developersdex http://www.developersdex.com ***




Norman Jones

VBA Code req to close all workbooks
 
Hi Bob,

A good suggestion.


Neil,

Should you wish to keep your Peronal.xls workbook open, as per Bob's
suggestion, then try this amendment:

'====================
Sub Workbook_Open()
Dim WB As Workbook

For Each WB In Application.Workbooks
If WB.Name < ThisWorkbook.Name _
And LCase(WB.Name) < "personal.xls" Then
WB.Close SaveChanges:=True
End If
Next WB

End Sub
'<<====================

---
Regards,
Norman



"Bob Phillips" wrote in message
...
You might also want to test for Personal.xls, you probably don't want to
close that.

--
HTH

Bob Phillips

"Neil Atkinson" wrote in message
...
Many Thanks I had forgot how simple that is...

Rgds
Neil

*** Sent via Developersdex http://www.developersdex.com ***







All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com