Excel 2010 - Public Function vs Function

I went into various sheets in my workbook using a message function I created. It worked in all sheets.  Even though I didn't preface my function with the word public.
What does "Public" do to function procedures that just having the word "function" doesn't do?
I see no difference because I was able to use the same function in every sheet in my workbook.
brothertruffle880Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Public makes it available anywhere in your workbook. It could also be Private, but without either it is assumed to be Public.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fabrice LambertFabrice LambertCommented:
As martin said, the Public or Private or Friend keyword define the visibility of your functions (or precedures):
- Public is visible from anywhere.
- Friend is visible only within the project.
- Private is visible only within the module.

Same goes with variables.

It is a good practice to explicitly define the visibility of your functions / variables, and restrict it as much as possible.
If a function is supposed to be called only within a module (or class), there is no reason to make it public.
0
brothertruffle880Author Commented:
Thanks Martin!
0
Martin LissOlder than dirtCommented:
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.