Call a sub routine from another module

Patricia0923

New Member
Joined
Mar 18, 2014
Messages
25
Hi,
I am writing a lot of code and have separated each section in different modules
For example, I have one module titled OpenR2D2 and another titled StoreName

I want the sub in StoreName to run at the end of OpenR2D2 but I get this compile error
"expected variable or procedure, not module"

Here's the end of the code where I put it. What have I not thought of? Thanks so much!

ThisWorkbook.Activate
Range("B9:G9").PasteSpecial

R2D2data.Activate
Range("B7:G7").Copy 'Sch Actual VLH


ThisWorkbook.Activate
Range("B12:G12").PasteSpecial

Call StoreName

R2D2data.Close Savechanges:=False


Application.ScreenUpdating = True


End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
When you use the Call statement, the parentheses are required. Try it this way...

Call StoreName()
 
Upvote 0
Don't name the module and the subroutine the same thing. Or, if you really must, you have to use
Code:
Call StoreName.Storename
 
Upvote 0
Hi,
Thanks for quick reply!
I actually renamed the Module.
I did not realize that having the module name and the sub routine name the same would cause a problem!
There's so much to know with VBA - are these little tricks written somewhere?


Thanks again - problem solved!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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