calling a module

chris2727272727

Board Regular
Joined
Jul 10, 2005
Messages
152
how do you go about calling a module that is not in the workbook that you are using ie one that is in another book
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
If you open both workbooks you can see all the macros in each book. Were you going to make a button and assign the macro or simply call the macro in code?
 
Upvote 0
Could you give us some more information?:)
 
Upvote 0
Try the Run Method as follows :

Code:
Sub Source_Macro()
    Application.Run "TergetWB.xls!Target_Macro"
End Sub

Where TargetWB is the name of the WorkBook housing the called Macro.
 
Upvote 0
You could use a inputbox.



Code:
 Sub Module()
    Dim VBComp As VBIDE.VBComponent
    Dim Module As String
    On Error Resume Next
    Module = InputBox("Put Module Name")
    Application.ActiveWorkbook.VBProject.VBComponents.Import ("C:\Documents\" & Module & ".bas")
    If Err = "53" Then
        MsgBox "Module does not exist!"
    End If
     
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,096
Messages
6,053,513
Members
444,669
Latest member
Renarian

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