Sub, Public Sub or Private Sub?

GR44

Board Regular
Joined
Nov 26, 2002
Messages
83
I'm confused about Sub, Public Sub and Private Sub.

I've got a macro that protects certain sheet, hides certain sheets and protects the workbook. I also have another that that unhides and unprotects them all. They can be launched by keying Cntrl+j and Cntrl+Shft_J, respectively. Right now they code resides in Module 5 and thus far work perfectly.

But both are not Private Subs so they can be seen by a user in the macro box. If I make them Private they won't run. Is there a way to make these macros executable and NOT be seen in the macro box?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Sub = Public Sub

Private Sub makes it available to other macros in the same module, but not to the user

To do what you want put (Hopes this doesn't confuse you even more)

Option Private Module

at the top.

But remember, the user won't see the macro in the macro list, but if they write the macro's name, they'll be able to execute it.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

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