Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all..........
Need code if you please to close all other open workbooks except the one I'm running the macro in. I do not know what their names are. TIA Vaya con Dios, Chuck, CABGx3 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try something like this
Dim WB as Workbook For each WB in Application.Workbooks if wb.name < thisworkbook.name then WB.Close 'You may want to save or do something else here end if next WB -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "CLR" wrote: Hi all.......... Need code if you please to close all other open workbooks except the one I'm running the macro in. I do not know what their names are. TIA Vaya con Dios, Chuck, CABGx3 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub clr()
nm = ThisWorkbook.Name Dim w As Workbook For Each w In Workbooks If w.Name = nm Then Else w.Close End If Next End Sub -- Gary''s Student - gsnu200817 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Barb.......
Appreciate the quick comeback......... Vaya con Dios, Chuck, CABGx3 "Barb Reinhardt" wrote: Try something like this Dim WB as Workbook For each WB in Application.Workbooks if wb.name < thisworkbook.name then WB.Close 'You may want to save or do something else here end if next WB -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "CLR" wrote: Hi all.......... Need code if you please to close all other open workbooks except the one I'm running the macro in. I do not know what their names are. TIA Vaya con Dios, Chuck, CABGx3 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Gary"s Student....
Appreciate the quick comeback Vaya con Dios, Chuck, CABGx3 "Gary''s Student" wrote: Sub clr() nm = ThisWorkbook.Name Dim w As Workbook For Each w In Workbooks If w.Name = nm Then Else w.Close End If Next End Sub -- Gary''s Student - gsnu200817 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code to close many open workbooks | Excel Programming | |||
Workbooks Close, but window stays open | Excel Discussion (Misc queries) | |||
close all open workbooks except the active one | Excel Programming | |||
Open Close workbooks | Excel Discussion (Misc queries) | |||
help with macro to open and close workbooks | Excel Programming |