Sub CLOSE_ALLbut()
myname = ActiveWorkbook.Name
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In Application.Workbooks
    If w.Name <> myname Then
    w.Close SaveChanges:=False
    End If
Next w
'Application.Quit
End Sub



Don Guillett
Microsoft MVP Excel
SalesAid Software
dguille...@gmail.com
-----Original Message----- From: LearnExcel
Sent: Wednesday, March 07, 2012 4:20 PM
To: MS EXCEL AND VBA MACROS
Subject: Re: $$Excel-Macros$$ vba code to kill all open workbooks

thanks works great...if you want the current workbook to remain open
where you're running the code  what needs to be changed?

ie:

Master file

book1
book2
book3
ect

close everything expect master file



On Mar 7, 8:32 am, "dguillett1" <dguille...@gmail.com> wrote:
How about  application.quit or

Sub CLOSE_ALL()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In Application.Workbooks
    w.Close SaveChanges:=false
Next w
'Application.Quit
End Sub

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguille...@gmail.com







-----Original Message-----
From: LearnExcel
Sent: Tuesday, March 06, 2012 8:24 PM
To: MS EXCEL AND VBA MACROS
Subject: $$Excel-Macros$$ vba code to kill all open workbooks

is there a VBA code that i can run that will kill all open
worksheets?

i open about 10 open excel files and once i'm done i want close all
work sheets WITHOUT SAVING.

i dont want any of my changes to affect the sheets can this be done?

--
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security
measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited.

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

--------------------------------------------------------------------------- ---------------------------
To post to this group, send email to excel-macros@googlegroups.com

--
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited.

NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com
--
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited.
NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to