![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 7
|
I have been trying to develop a macro which will count the number of files in a known directory (defined in a string). I would also like to open these one by one to extract data from them. Anyone know how to do this other than forcing the user to open them one by one using GetOpenFilename?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the following code:
Dim fs, f, f1, fc Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder("C:YourPath") Set fc = f.Files For Each f1 In fc Workbooks.Open f1.Path Next Subsitute your folder for C:YourFolder. The code finds all files in the folder and opens them.
__________________
Kind regards, Al Chara |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|