Calling a Macro from another workbook

Hi Rory,

I receive Run-time error '424': Object required and it highlights the code line:
Code:
Application.Run "'" & TrackingWorkbook.Name & "'!GlobalRemNamedRanges"

I think it might be with the macro itself? originally it had Option Explicit, but I removed that in testing and still get the same error. The code is:
Code:
Sub GlobalRemNamedRanges()     
    Dim nm As Name
     
    On Error Resume Next
        For Each nm In ActiveWorkbook.Names
            nm.Delete
        Next
    On Error GoTo 0
     
End Sub

Any ideas?
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
That error means that you never assigned an object to the TrackingWorkbook variable.
 
Upvote 0
No, it would be a Workbook object and you need to assign the relevant workbook to it using Set.
 
Upvote 0
Ahh ok so then I have a follow-up question. when you say relevant workbook wouldn't I be entering in the specific workbook to go from? But my issue is that the origniating "relevant" workbook could be any of 20+ (MBU-TrackingWorkbook, SPD-TrackingWorkbook, etc.) Since those workbooks haven't been created yet, and I didn't want to have the admin overhead of setting each one up individually, how to I denote the relevant workbook? It would be the one currently open that has the name ****-TrackingWorkbook.xlsm (* as wildcard), but I am not sure how to do this. I am very new to vba and know just enough to be dangerous but not competent :)
 
Upvote 0
This should really be its own thread as it has nothing to do with the original one.

You need to loop through the workbooks and test the name of each one. As it happens, I've just answered an almost identical question here.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top