ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically applying a macro to many workbooks (https://www.excelbanter.com/excel-programming/304214-re-automatically-applying-macro-many-workbooks.html)

Chip Pearson

Automatically applying a macro to many workbooks
 
Open all the workbooks, and then run code like


Dim WB As Workbook
For Each WB In Workbooks
WB.Activate
' call your macro here
Next WB



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"davidoo2005" wrote in
message
...
I have some 2000 books that each contain one data table to

process. Is there any way to automate a macro to process these
books without individually running the macro for each book?



davidoo2005

Automatically applying a macro to many workbooks
 
Thanks. How can I exclude personal.xls from the for loop?

"Chip Pearson" wrote:

Open all the workbooks, and then run code like


Dim WB As Workbook
For Each WB In Workbooks
WB.Activate
' call your macro here
Next WB



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"davidoo2005" wrote in
message
...
I have some 2000 books that each contain one data table to

process. Is there any way to automate a macro to process these
books without individually running the macro for each book?




Dave Peterson[_3_]

Automatically applying a macro to many workbooks
 
Dim WB As Workbook
For Each WB In Workbooks
if lcase(wb.name) < "personal.xls" then
WB.Activate
' call your macro here
end if
Next WB

davidoo2005 wrote:

Thanks. How can I exclude personal.xls from the for loop?

"Chip Pearson" wrote:

Open all the workbooks, and then run code like


Dim WB As Workbook
For Each WB In Workbooks
WB.Activate
' call your macro here
Next WB



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"davidoo2005" wrote in
message
...
I have some 2000 books that each contain one data table to

process. Is there any way to automate a macro to process these
books without individually running the macro for each book?




--

Dave Peterson



All times are GMT +1. The time now is 09:33 AM.

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