View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default opening multiple files from within a macro

Dim sPath as String, sName as String
Dim bk as Workbook
sPath = "C:\Myfolder\"
sName = Dir(sPath & "*.xls")
do while sName < ""
set bk = workbooks.open(sPath & sName)
. . . process bk
bk.close Savechanges:=False ' or true
sName = Dir
Loop

--
Regards,
Tom Ogilvy


"Srikanth" wrote in message
om...
Hello,

I want to be able to run the same macro on say all the excel files in
a given folder. (without me having to select each file). I want to be
able to select the appropriate folder(that contains all the excel
files) and the macro should do the rest. What is the best way to do
that ? Please help.

Thanks

Srikanth