Home

User Defined Function not showing with up "="

%3CLINGO-SUB%20id%3D%22lingo-sub-286946%22%20slang%3D%22en-US%22%3EUser%20Defined%20Function%20not%20showing%20with%20up%20%22%3D%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-286946%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20few%20UDFs'%20that%20i%20have%20written%20for%20practice%20since%20i'm%20just%20getting%20into%20the%20programming%20portion%20of%20VBA.%26nbsp%3B%20I%20have%203%20Projects%20in%20my%20vba%20window.%201%20for%20macros%2C%201%20for%20my%20UDF%2C%20and%20the%20last%20one%20is%20whatever%20workbook%20i%20have%20opened.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20question%20is%20how%20can%20i%20get%20my%20functions%20to%20show%20up%20when%20typing%20%22%3D%22.%26nbsp%3B%20I%20have%20searched%20google%20and%20the%20only%20answer%20that%20i%20came%20up%20with%20is%20i%20have%20to%20attach%20the%20module%20that%20has%20the%20function%20into%20the%20current%20workbook.%26nbsp%3B%20My%20functions%20do%20work%20and%20show%20up%20when%20using%20%22%3D%22%20but%20it%20is%20a%20little%20annoying%20to%20have%20to%20attach%20them%20to%20every%20workbook%20i%20create%20since%20im%20dealing%20with%20new%20and%20multiple%20workbooks%20everyday.%26nbsp%3B%20I%20also%20know%20that%20the%20%22insert%20function%22%20is%20under%20the%20formula%20tab%20and%20that%20works%20as%20well%20but%20still%20an%20annoyance.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20seems%20like%20there%20is%20an%20easier%20better%20way.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%20the%20functions%20are%20public%2C%20No%20the%20module%20names%20are%20not%20the%20same%20as%20the%20function%20name.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-286946%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFunctions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUDF%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EVba%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-287363%22%20slang%3D%22en-US%22%3ERe%3A%20User%20Defined%20Function%20not%20showing%20with%20up%20%22%3D%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-287363%22%20slang%3D%22en-US%22%3Elol%20there%20is%20an%20s%20and%20no%20period%20in%20my%20actual%20code%2C%20those%20are%20just%20typos%20from%20when%20i%20was%20writing%20it%20here.%3CBR%20%2F%3E%3CBR%20%2F%3Ebtw%20that%20worked!%20thank%20you%20so%20much.%20sorry%20about%20the%20all%20caps%20had%20caps%20lock%20on.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-287295%22%20slang%3D%22en-US%22%3ERe%3A%20User%20Defined%20Function%20not%20showing%20with%20up%20%22%3D%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-287295%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Katrina%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20sorry%20about%20that!%3C%2FP%3E%3CP%3EI%20forgot%20that%20this%20only%20works%20in%20the%20subroutines%20(Subs)%2C%20not%20in%20the%20functions!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20regards%20to%20the%20functions%2C%20you%20need%20to%20create%20a%20new%20workbook%20and%20save%20the%20function%20in%20a%20module%20in%20this%20workbook%2C%20then%20you%20have%20to%20save%20this%20workbook%20as%20%3CSTRONG%3EExcel%20Add-in%20(*.xlam)%3C%2FSTRONG%3E%20file%20extension.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20that%2C%20you%20need%20to%20copy%20this%20workbook%20into%20the%20%3CSTRONG%3EXLSTART%3C%2FSTRONG%3E%20folder.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20locate%20this%20folder%2C%20please%20follow%20this%20path%3A%3C%2FP%3E%3CP%3EC%3A%5CUsers%5C%3CSTRONG%3E%3CUSERNAME%3E%3C%2FUSERNAME%3E%3C%2FSTRONG%3E%5CAppData%5CRoaming%5CMicrosoft%5CExcel%5CXLSTART%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20please%20note%20that%20the%20code%20you%20attached%20seems%20to%20be%20wrong!%3C%2FP%3E%3CP%3EIt's%20%3CSTRONG%3EOption%20Explicit%3C%2FSTRONG%3E%20(Option%20without%20%3CSTRONG%3Es%3C%2FSTRONG%3E).%3C%2FP%3E%3CP%3EAlso%2C%20you%20have%20to%20remove%20the%20period%20(.)%20after%20the%20%3CSTRONG%3EEnd%20Function%3C%2FSTRONG%3E!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-287257%22%20slang%3D%22en-US%22%3ERe%3A%20User%20Defined%20Function%20not%20showing%20with%20up%20%22%3D%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-287257%22%20slang%3D%22en-US%22%3ETRIED%20THIS.%20DOES%20NOT%20WORK.%20I%20HAVE%20TO%20ATTACH%20A%20COPY%20OF%20THE%20MODULE%20DIRECTLY%20TO%20THE%20WORKSHEET%20IM%20USING%20FOR%20IT%20TO%20SHOW%20UP%20WHEN%20TYPING%20%22%3D%22.%20DOES%20THERE%20HAVE%20TO%20BE%20SOMETHING%20SPECIAL%20IN%20THE%20CODE%20FOR%20IT%20TO%20WORK%3F%20RIGHT%20NOW%20IT%20JUST%20LOOKS%20LIKE%3B%3CBR%20%2F%3E%3CBR%20%2F%3EOPTIONS%20EXPLICIT%3CBR%20%2F%3EPUBLIC%20FUNCTION%20BUYBACK%20(SUBCAT%20AS%20STRING%2C%20UPRICE%20AS%20SINGLE)%3CBR%20%2F%3EIF%20CODE%20YADADADADADA%3CBR%20%2F%3EEND%20IF%3CBR%20%2F%3EEND%20FUNCTION.%3CBR%20%2F%3E%3CBR%20%2F%3EDIDN'T%20FEEL%20LIKE%20PUTTING%20THE%20MILE%20LONG%20CODE%20LOL.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-286986%22%20slang%3D%22en-US%22%3ERe%3A%20User%20Defined%20Function%20not%20showing%20with%20up%20%22%3D%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-286986%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Katrina%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20save%20the%20UDFs%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2FCopy-your-macros-to-a-Personal-Macro-Workbook-AA439B90-F836-4381-97F0-6E4C3F5EE566%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPersonal%20Macro%20Workbook%3C%2FA%3E%20in%20order%20to%20make%20them%20available%20to%20all%20open%20workbooks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20more%20info%2C%20please%20check%20out%20this%20%3CA%20href%3D%22https%3A%2F%2Ftrumpexcel.com%2Fpersonal-macro-workbook%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Elink%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-448427%22%20slang%3D%22en-US%22%3ERe%3A%20User%20Defined%20Function%20not%20showing%20with%20up%20%22%3D%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-448427%22%20slang%3D%22en-US%22%3EYour%20Post%20Saved%20Me%20Today!!!%20I%20fought%20with%20a%20user%20defined%20function%20for%20hours%2C%20could%20not%20get%20it%20to%20work%20just%20kept%20getting%20the%20%22%23NAME!%22%20error.%3CBR%20%2F%3E%3CBR%20%2F%3EThen%2C%20read%20your%20post%20and%20forgot%20to%20put%20it%20in%20the%20XLSTART%20folder.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks!%3C%2FLINGO-BODY%3E
katrina bethea
Contributor

I have a few UDFs' that i have written for practice since i'm just getting into the programming portion of VBA.  I have 3 Projects in my vba window. 1 for macros, 1 for my UDF, and the last one is whatever workbook i have opened.

 

My question is how can i get my functions to show up when typing "=".  I have searched google and the only answer that i came up with is i have to attach the module that has the function into the current workbook.  My functions do work and show up when using "=" but it is a little annoying to have to attach them to every workbook i create since im dealing with new and multiple workbooks everyday.  I also know that the "insert function" is under the formula tab and that works as well but still an annoyance.

 

Just seems like there is an easier better way.

 

Yes the functions are public, No the module names are not the same as the function name.

5 Replies
Highlighted

Hi Katrina,

 

You can save the UDFs in the Personal Macro Workbook in order to make them available to all open workbooks.

 

For more info, please check out this link.

 

Hope that helps

TRIED THIS. DOES NOT WORK. I HAVE TO ATTACH A COPY OF THE MODULE DIRECTLY TO THE WORKSHEET IM USING FOR IT TO SHOW UP WHEN TYPING "=". DOES THERE HAVE TO BE SOMETHING SPECIAL IN THE CODE FOR IT TO WORK? RIGHT NOW IT JUST LOOKS LIKE;

OPTIONS EXPLICIT
PUBLIC FUNCTION BUYBACK (SUBCAT AS STRING, UPRICE AS SINGLE)
IF CODE YADADADADADA
END IF
END FUNCTION.

DIDN'T FEEL LIKE PUTTING THE MILE LONG CODE LOL.

Hi Katrina,

 

I'm sorry about that!

I forgot that this only works in the subroutines (Subs), not in the functions!

 

With regards to the functions, you need to create a new workbook and save the function in a module in this workbook, then you have to save this workbook as Excel Add-in (*.xlam) file extension.

 

After that, you need to copy this workbook into the XLSTART folder.

 

To locate this folder, please follow this path:

C:\Users\<username>\AppData\Roaming\Microsoft\Excel\XLSTART

 

But please note that the code you attached seems to be wrong!

It's Option Explicit (Option without s).

Also, you have to remove the period (.) after the End Function!

 

Hope that helps

lol there is an s and no period in my actual code, those are just typos from when i was writing it here.

btw that worked! thank you so much. sorry about the all caps had caps lock on.
Your Post Saved Me Today!!! I fought with a user defined function for hours, could not get it to work just kept getting the "#NAME!" error.

Then, read your post and forgot to put it in the XLSTART folder.

Thanks!
Related Conversations
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
2 Replies
*Updated 9/3* Syncing in Microsoft Edge Preview Channels
Elliot Kirk in Articles on
205 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies