VBA: Call Macros

AD_Taylor

Well-known Member
Joined
May 19, 2011
Messages
687
Hi,

I have a Sub which I don't want to be seen in the Run Macros window but I do want to be able to call from other Modules inside my code.

For example I want to be able to call it from a Worksheet_Change event. But I specifically don't want users to be able to see and/or run it.

I thought the way around this would be a Private Sub but then only code in the same Module can call it.

Any ideas?
- Adam
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Add this line to the top of the code module (the same place where you have Option Explicit):

Code:
Option Private Module
 
Upvote 0
Then: Private AND write the macro in the same "sheet code module" that contains the Worksheet_Change macro.

Bye
 
Upvote 0
Add this line to the top of the code module (the same place where you have Option Explicit):

Code:
Option Private Module

Perfect! Thanks for the answer Colin :)

Then: Private AND write the macro in the same "sheet code module" that contains the Worksheet_Change macro.

Bye

This would be great if i didn't want to organise my code lol. I have a lot of subs that do similar things so I've grouped them in one module - I don't think it'd be a good idea to spread them randomly all over the place just so I can call them.
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,802
Members
452,943
Latest member
Newbie4296

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