closing multi workbooks

H

have_a_cup

first, thanks to anyone who helps out w/ this..i've tried a couple o
different things, and just keep messing up my macro...so as simple a
it may be, i bring nothing to the table here....

I have up to 50 workbooks named 'rec 1', 'rec 2' etc....
I run a macro to move specified sheets to a new wbk called 'rec indi'

after all the moves how do I close all of the 'rec' files ? wha
syntax is used to replace ("BOOK1.XLS")??? to close all rec files?


Application.DisplayAlerts = False
Workbooks("BOOK1.XLS").Close
Application.DisplayAlerts = Tru
 
G

Guest

Try this:

For Each Workbook In Workbooks
If Left(Workbook.Name, 3) = "rec" Then
Workbook.Close
End If
Next

-Simon
 
H

have_a_cup

great...thanks SimonCC....worked like a charm....off to make more of
confused state on my project...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top