LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Cycling through all worbooks in a folder

This code will give you a starting point:

Sub aa()
Set fso =
CreateObject("Scripting.FileSystemObject").GetFold er("c:\OurFiles\")
For Each file In fso.Files
If file.Type = "Microsoft Excel Worksheet" Then
With file
' do what you want with this file
End With
End If
Next
Set fso = Nothing
End Sub

Note: Replace "C:\OURFILES" by your folder; this code does not recurse the
foldre tree if it has one.

"Ben" wrote:

I would like to perform a piece of code on every workbook in a folder and
then close it. What would be the best way please. Thank you

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab keeps cycling through the same row Mike Excel Discussion (Misc queries) 2 August 14th 08 12:20 AM
Opening worbooks with a variable file name. ibbm Excel Programming 5 January 5th 06 02:58 AM
Clarification on "Application.Worbooks.Count" proceedure Les Stout[_2_] Excel Programming 8 November 2nd 05 07:12 PM
cycling through columns? Kirk Excel Programming 2 May 2nd 05 07:51 PM
Cycling through variables. Azza Excel Programming 1 October 14th 04 10:23 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"