Run a recorde macro in multiple excel workbook at a time
In message
s.com of Tue, 7 Dec 2010 23:17:11 in microsoft.public.excel.programming
, yogi writes
Dear all,
i have reorded macro for formating data , i have more than 150 files
in which i have to run this macro. Is there is any code by which i can
run my recorded macro in 150files at a time.
It might be nice if you said which version of Excel you use. The
solution might be different for different versions.
I assume running a macro in 150 files, one at a time is acceptable.
I assume a folder object will give you the names of files which include
those you want to run. help folder in Visual Basic Window will help.
I would construct pseudo code like:
set folder = root folder
call tree folder
sub tree(folder)
for each file in folder
if relevant file then Call Macro file
next file
for each subfolder in folder
if relevant subfolder then call tree subfolder
next subfolder
end sub
I run a given macro on up to about 10 files in one folder by selecting
the names in Windows Vista and opening the files in Excel 2003.
I then run code like this:
Dim wq As Workbook
call initialisation
For Each wq In Workbooks
SingleFileAction
Next wq
I am sorry not to be more helpful.
If you can expand your requirement, you may get more specific help.
Please say how you get on.
--
Walter Briscoe
|