UDFs: The difference between function and public function?

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,224
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,569
Messages
5,596,912
Members
414,110
Latest member
docops

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