Thread
:
Application.Run for every open workbooks (one by one)
View Single Post
#
2
Posted to microsoft.public.excel.programming
Dave Peterson
external usenet poster
Posts: 35,218
Application.Run for every open workbooks (one by one)
Notice your syntax:
"FirstFile.xls!SameMacroButStoredInThisSpecificWor kbook"
You have an exclamation mark after the workbook name and you use the workbook
name.
Application.Run "'" & wbk.name & "'!SameMacroButStoredInThisSpecificWorkbook"
The apostrophes are sometimes required--depending on the name of the file. But
they never hurt if you include them.
wrote:
Hi guys,
One question:
Do you know how to convert the macro:
Sub UglyMacro ()
Application.Run
"FirstFile.xls!SameMacroButStoredInThisSpecificWor kbook"
ActiveWindow.ActivateNext
Application.Run
"SecondFile.xls!SameMacroButStoredInThisSpecificWo rkbook"
ActiveWindow.ActivateNext
Application.Run
"ThirdFile.xls!SameMacroButStoredInThisSpecificWor kbook"
ActiveWindow.ActivateNext
End Sub
into macro that will go like:
Sub DraftNiceMacro ()
For each wbk in Application.Workbooks
Application.Run "wbk.SameMacroButStoredInThisSpecificWorkbook"
Next wbk
End Sub
This one is not working for some strange reason...
Thanks for your help,
Mark
--
Dave Peterson
Reply With Quote
Dave Peterson
View Public Profile
Find all posts by Dave Peterson