Run same name code on different modules

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Run same name code on different modules

Post by Rudi »

Hi

As in the image, I gave a macro that must run with specific (listed) filters and then it must run again with criteria being Unlisted.

Is it possible to have the code running listed filter on one module
Have code running unlisted on another module and then refer to code like this (or similar):

Code: Select all

Sub Test()
PrepSheets
Listed.Filter2Z
Listed.Filter2NZ
UnListed.Filter2Z
UnListed.Filter2NZ
CreateTotals
End Sub
SP5-Wed,6-11.jpg
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Run same name code on different modules

Post by HansV »

Yes, that is possible. Take care never to call Filter2Z or Filter2NZ without prefixing it with the module name.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Run same name code on different modules

Post by Rudi »

How do I do that?
Getting errors...
SP6-Wed,6-11.jpg
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Run same name code on different modules

Post by HansV »

If you have declared Filter2Z as

Sub Filter2Z()

or as

Public Sub Filter2Z()

you can call it as

Listed.Filter2Z

But if you have declared it as

Private Sub Filter2Z()

you must use

Application.Run "Listed.Filter2Z"
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Run same name code on different modules

Post by Rudi »

Many TX.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.