Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close all other workbooks but this one?
If I have 3 workbooks open and I only want to have open (this) workbook
is there a way to make excel find the number of open worksheets an close them all apart from this open one -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close all other workbooks but this one?
Sub test()
Dim WB As Workbook For Each WB In Application.Workbooks If WB.FullName < Me.FullName Then WB.Close Next End Sub As is it will ask "save changes ?" for each one. HTH. Best wishes Harald "ianripping " skrev i melding ... If I have 3 workbooks open and I only want to have open (this) workbook, is there a way to make excel find the number of open worksheets and close them all apart from this open one? --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close all other workbooks but this one?
Sub close_all_other_workbooks()
ThisWkbk = ActiveWorkbook.Name For i = Workbooks.Count To 1 Step -1 If Workbooks(i).Name < ThisWkbk And Workbooks(i).Name < "Personal.xls" Then Workbooks(i).Close 'False End If Next End Sub Uncommenting the False switch will close without saving, using True instead will save and close; as is, you will be prompted. HTH, Nikos "ianripping " wrote in message ... If I have 3 workbooks open and I only want to have open (this) workbook, is there a way to make excel find the number of open worksheets and close them all apart from this open one? --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close all other workbooks but this one?
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
why do all excel worksheets/workbooks close when I close one? | Excel Discussion (Misc queries) | |||
Open Close workbooks | Excel Discussion (Misc queries) | |||
Why does Excel close all workbooks? | Setting up and Configuration of Excel | |||
So close yet so far - combining workbooks | Excel Programming | |||
help with macro to open and close workbooks | Excel Programming |