ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   lots of makros into one makro?? (https://www.excelbanter.com/excel-programming/369047-lots-makros-into-one-makro.html)

JVLennox[_12_]

lots of makros into one makro??
 

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!


--
JVLennox
------------------------------------------------------------------------
JVLennox's Profile: http://www.excelforum.com/member.php...o&userid=32505
View this thread: http://www.excelforum.com/showthread...hreadid=567219


NickHK

lots of makros into one makro??
 
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

"JVLennox" wrote in
message ...

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!


--
JVLennox
------------------------------------------------------------------------
JVLennox's Profile:

http://www.excelforum.com/member.php...o&userid=32505
View this thread: http://www.excelforum.com/showthread...hreadid=567219




JVLennox[_13_]

lots of makros into one makro??
 

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
-------------------

--
JVLenno
-----------------------------------------------------------------------
JVLennox's Profile: http://www.excelforum.com/member.php...fo&userid=3250
View this thread: http://www.excelforum.com/showthread.php?threadid=56721


JVLennox[_14_]

lots of makros into one makro??
 

I got it!

I just have to add this line:
Filename = Dir()

THANKS anyway!

--
JVLenno
-----------------------------------------------------------------------
JVLennox's Profile: http://www.excelforum.com/member.php...fo&userid=3250
View this thread: http://www.excelforum.com/showthread.php?threadid=56721



All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com