ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   launch macro in other workbook (https://www.excelbanter.com/excel-programming/428197-launch-macro-other-workbook.html)

pls123

launch macro in other workbook
 
hi all !!
i have this but it gives error for each "wb"...

For Each wb In Workbooks
If (left(wb.name,1) )= "_" Then
Call mymacro
End if
Next wb

....it is inside a sub that starts like this...

Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")


can anybody help pls !!

Per Jessen[_2_]

launch macro in other workbook
 
Hi

You have to use the parent object as reference:

For Each wb In Application.Workbooks


Regards,
Per

On 8 Maj, 13:08, pls123 wrote:
hi all !!
*i have this but it gives error for each "wb"...

For Each wb In Workbooks
If (left(wb.name,1) )= "_" Then
* *Call mymacro
*End if
*Next wb

...it is inside a sub that starts like this...

Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

can *anybody help pls !!



Przemek[_2_]

launch macro in other workbook
 


For Each wb In Workbooks
If (left(wb.name,1) )= "_" Then application.run wb.name &"!" & mymacro
Next wb





pls123

launch macro in other workbook
 
thx all !! i will test in the weekend !!

"Przemek" wrote:



For Each wb In Workbooks
If (left(wb.name,1) )= "_" Then application.run wb.name &"!" & mymacro
Next wb







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

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