launch macro in other workbook

P

pls123

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

Per Jessen

Hi

You have to use the parent object as reference:

For Each wb In Application.Workbooks


Regards,
Per
 
P

Przemek

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

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

Similar Threads

this should work.. 5
calling sub from other workbook 1
fill a cell with this.. 4
range calculate 5
error 1004 6
Redefining chart series 1
automatic replacing of vbe code for multiple workbooks 1
timer issue 5

Top