PC Review


Reply
Thread Tools Rate Thread

Close all other open Workbooks

 
 
CLR
Guest
Posts: n/a
 
      5th Dec 2008
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


 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      5th Dec 2008
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
>
>

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      5th Dec 2008
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 With Quote
 
CLR
Guest
Posts: n/a
 
      5th Dec 2008
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
> >
> >

 
Reply With Quote
 
CLR
Guest
Posts: n/a
 
      5th Dec 2008
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open and close workbooks JOSEPH WEBER Microsoft Excel Programming 1 15th Apr 2010 03:25 PM
Open and Close Workbooks Tontonan Microsoft Excel Programming 2 18th Feb 2009 09:41 PM
Open Close workbooks =?Utf-8?B?YmJjMQ==?= Microsoft Excel Misc 2 28th Aug 2005 11:24 AM
Re: Close Open Workbooks Frank B Microsoft Excel Misc 0 10th Sep 2003 07:09 PM
Re: Close Open Workbooks Bob Phillips Microsoft Excel Misc 0 10th Sep 2003 07:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:35 PM.