Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm want to use the Private Sub functions provided here.

Usually a put VBA code in the Visual Basic Editor, I then close the editor and I run the code using "Run this Macro" on the Developer tab. But in this case, the function doesn't appear.

Where do I need to put this code to run it?

share|improve this question

The private macros doesn't show in the macro options by default, as they are marked private (Private keyword prevents a macro from showing in the macro list).

Usually, the only macros that need to be private in Excel are the worksheet/workbook events, or macros refered by other macros that don't need to be accessed by the user. As you are not in this case, you may try to make the macros public by removing the Private at the beginning of the sub definition).

share|improve this answer

To use the code you found on the website:

In the Visual Basic editor, on the left hand side under Project-VBA Project, go to where it says VBAProject (<Your workbook name here>) and under Microsoft Excel Objects double click one of the sheets, and a blank code file will open up.

On the dropdown on the left side, select Worksheet and then select SelectionChange on the right, fill in the code from the website you linked. This is an event driven subroutine, which means when you change the selection, this code will be run automatically.

enter image description here For a private subroutine that's not event related, create a public Sub() which Calls the private one.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .