For each File in Folder, open?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I like to specify a folder, then have the excel files in the folder open one
at a time for a macro to run on it. How can I do that?
 
maybe something like this:

Sub GetFileList()
Dim ThePath As String
Dim fname As String
Dim i As Long
ThePath = ThisWorkbook.Path
fname = Dir(ThePath & "\*.xls")
i = 1
Do While fname <> ""
On Error Resume Next
Workbooks.Open Filename:=fname
On Error GoTo 0
fname = Dir()
i = i + 1
Loop
End Sub
 

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

Back
Top