Opening all files located in a specific directory

D

DaSo

Hi everybody,

Having done just a few macros for Excel, I´m a total beginner in VB and
I would like to ask you how to open all files located in a specific
directories at once. I thought the following might work, but it doesn´t:

Sub Makro1()

ChDir "C:\user\Results"
Workbooks.Open FileName:="*.*"

End Sub


Any help?
 
T

Tom Ogilvy

Sub Makro1()

ChDir "C:\user\Results"
fName = Dir("C:\user\Results\*.xls")
do while fName <> ""
workbooks.Open fName
fName = dir()
Loop

End Sub

Assumes you don't have any directories with a .xls extension.
 

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

Similar Threads


Top