lots of makros into one makro??

J

JVLennox

Hi!

I have a folder with hundreds of xls-files. Each file contains the
macro "ALLNUMBERS".
Is there a way that I can run all makros without having to open each
file and run each makro by hand?

THANKS!
 
N

NickHK

No, the file has to be open for the code to run.
But you could automate the process:
<psuedo-code>
Foldname=get the folder name
filename=dir(foldername & "*.xls") 'Or filter as necessary
do while filename<>""
set WB=workbooks.open(filename)
application.run wb.name & "!ALLNUMBERS"
wb.close 'true/false if you want to save changes/or not
loop
<psuedo-code>

NickHK
 
J

JVLennox

THANKS, to automate is good enough!!

I applied the code, BUT it loops WITHOUT going to the next filename (i
always uses the first file in the folder)
How do I make it take the next file???

THANKS


Code
-------------------
Sub START()
Foldname = "C:\1\"
Filename = Dir(Foldname & "*.xls") 'Or filter as necessary
Do While Filename <> ""
Set wb = Workbooks.Open(Foldname & Filename)
'Application.Run wb.Name & "!ALLNUMBERS"
wb.Close 'true/false if you want to save changes/or not
Loop

End Su
 

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

Top