ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For each File in Folder, open? (https://www.excelbanter.com/excel-programming/394310-each-file-folder-open.html)

J@Y

For each File in Folder, open?
 
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?

Gary Keramidas

For each File in Folder, open?
 
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


--


Gary


"J@Y" wrote in message
...
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?




Ron de Bruin

For each File in Folder, open?
 
See also this example
http://www.rondebruin.nl/copy4.htm

You can change the copy/chnage code to your code



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"J@Y" wrote in message ...
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?



All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com