UDFs: The difference between function and public function?

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,273
Re: UDFs: The difference between function and public functio

A User Defined Function's scope is defaulted to Public, so if you don't specify Public it will still be regarded as Public by Excel. Public means for UDFs what it means for other declarations, that being the function can be accessed by other procedures in other modules in the workbook. Private scope makes the UDF accessible to procedures in the same module. The other optional scope is called Static, which keeps the variables' values unchanged between function calls.

A Private UDF does not appear in the Function dialog (something I personally never use anyway), and it is usually specified so a user does not attempt to use it as a formula because the workbook author's intent for the UDF is to support other VBA procedures.

Bottom line to your specific question, Public is the default scope so you can leave it out if you want the UDF to be Public.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,955
Messages
5,856,498
Members
431,818
Latest member
AKEMAROD

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
Top