+ Reply to Thread
Results 1 to 6 of 6

Create & Use a UDF Without a Workbook Reference

  1. #1
    Registered User
    Join Date
    02-15-2017
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Home & Office 2010
    Posts
    3

    Create & Use a UDF Without a Workbook Reference

    I am going berserk trying to do something that I would expect to be straightforward. I have searched for the last 3 days to get directions, but have run into numerous false leads and dead-ends.

    I have a UDF (call it MyUDF) that I would like to use in any workbook I open on my computer (only) and I'd like to refer to it via only the function name without a qualifying workbook name (e.g. =MyUDF(args) instead of ='MyUDFWorkbook'!MyUDF(args)). I have had this working in the past (used in 50+ workbooks), though I must admit to not understanding/remembering how enough to be able to recreate it. I had programmed the UDF in a uniquely named workbook I saved as an Excel Add-In (i.e. with a .xlam extension). I'm not wedded to that approach, but am willing to use it again. I broke this several days ago when trying to overcome an Interop.Excel exception I was getting in a C# Winforms app I'm creating.

    I have read about and tried programming the UDF in PERSONAL.XLSB instead of a uniquely named workbook, overtly putting that workbook or my uniquely named one in the Excel AddIns and/or XLSTART folders (under my Windows user name), setting the IsAddIn property somehow (I could find how to do that), using the Add-Ins manager (which is still showing the name of my UDF even though I've deleted it from both the AddIns and XLSTART folders), and other things. There are moments where things I've tried seem to work, but then they don't when I shut down Excel and reopen the workbooks that use the UDF.

    I'd really appreciate guidance on how to clear out any residual junk I may have created and start over to get this to work. I'm using MS Office Home & Business 2010 on a Windows 8.1 machine. Thanks.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,432

    Re: Create & Use a UDF Without a Workbook Reference

    It might be difficult to pin this down over the internet.

    I store all of my UDF's in add-ins. The UDF's are then readily accessible to any open workbook. That is the approach I would recommend.

    It sounds like, in some of your wanderings on this issue, you have installed a few different add-ins. I had an issue once with an add-in that I tried to install twice and the second (correct) installation would not "stick" http://www.excelforum.com/excel-gene...or-add-in.html Something like that may be going on in your case as well.

    My advice at this point (and it is probably worth about what you paid for it) would be to:
    1) think through your UDF's and get them all into one or more add-ins. Store the add-in where you want it.
    2) Clear out the add-in registry in Excel so Excel can "forget" all of the previous attempts to install add-ins
    3) Install the add-in(s) with your UDF's
    4) Test to see if everything is working.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    02-15-2017
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Home & Office 2010
    Posts
    3

    Re: Create & Use a UDF Without a Workbook Reference

    Thanks for the attempt to help, but I'm afraid I don't understand or something else is going haywire.
    1) I have my UDF in an xlam in a personal folder. The xlam file has the same name as the UDF (surely that's OK).
    2) I renamed the xlam file to hide it from Excel. I went to File / Options / Add-Ins / Manage Excel Add-Ins Go. I unchecked the box next to MyUDF which triggered a message saying it couldn't find it and asking if I wanted to remove it. I said yes and it went away.
    3) I closed Excel. I then reopened Excel and went back to File / Options / Add-Ins / Manage Excel Add-Ins Go. I Browsed to and selected my xlam file with the new name. MyUDF reappeared in the pop-up list of available Add-Ins with the box checked. (It's the only one checked of the 5 Add-Ins that are shown). I clicked OK.
    4) I closed Excel and opened one of the workbooks that uses MyUDF. Excel asked if I wanted to Update the links to other sources. I clicked Update. It said I had one or more links that couldn't be updated. I clicked Continue. I looked at one of the references to MyUDF. It was fully qualified with the name of the original xlam file. I edited the formula by deleting the file qualification. It still showed a #Name? error. I tried to fully qualify the UDF with the path to my xlam file. Excel accepted the new formula, dropped the path info and left only the name of the xlam file as the qualification. This new formula still had a #Name? error.

    Once again, I'm at a loss. As a 1960s mainframe systems programmer who was away from technology for 30 years and taught himself C#/.Net/etc in the last few years, you would think I could figure this out. The evidence suggests otherwise. [P.S. I'm thinking about buying help to get around this problem, but can't find out what it means to buy 20 points for 30 days for $20. Grrrr.]

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,432

    Re: Create & Use a UDF Without a Workbook Reference

    The xlam file has the same name as the UDF (surely that's OK).
    I am not sure that it is, and I have never tried it (my add-ins usually have a name like "mystatisticsudfs.xla(m)" and the functions have names specific to the function). I know that you get a naming conflict if the function name is the same as the module name, but I don't know about file name (since filename includes the xla(m) extension, I'm not sure why it would trigger a naming conflict).
    I closed Excel and opened one of the workbooks that uses MyUDF. Excel asked if I wanted to Update the links to other sources. I clicked Update. It said I had one or more links that couldn't be updated. I clicked Continue. I looked at one of the references to MyUDF. It was fully qualified with the name of the original xlam file.
    That sounds a lot like the scenario I described above. I don't know why when Excel asks to remove a missing addin from the list it does not also remove the addin name/path from the list it stores in the system registry, but it does not seem to delete it from that list. I would suggest you at least look at the registry and see what Excel has in that list.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Create & Use a UDF Without a Workbook Reference

    Quote Originally Posted by sfrehling View Post
    4) I closed Excel and opened one of the workbooks that uses MyUDF. Excel asked if I wanted to Update the links to other sources. I clicked Update. It said I had one or more links that couldn't be updated. I clicked Continue. I looked at one of the references to MyUDF. It was fully qualified with the name of the original xlam file. I edited the formula by deleting the file qualification. It still showed a #Name? error. I tried to fully qualify the UDF with the path to my xlam file. Excel accepted the new formula, dropped the path info and left only the name of the xlam file
    Hi,

    First, I suggest that you ensure the UDF is not stored in a module with the same name (the name of the workbook is not relevant).

    If that is already the case, then I suggest at this stage you replace all the calls to your UDF with some static text. In other words replace
    ='c:\the path to your add-in\add-in name.xlam'!function_Name(...)
    with for example
    ||function_Name(...)
    Doing this with the Find/Replace dialog shold be simple. Then save and close the file.

    Now reopen the file and replace the double pipe characters with an = symbol. Hopefully that will rectify your problem.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Registered User
    Join Date
    02-15-2017
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Home & Office 2010
    Posts
    3

    Re: Create & Use a UDF Without a Workbook Reference

    Again, thanks for your quick and thorough help. My module name is different than my function name, so no problem there.

    I appreciate your suggestion for getting past the qualified function references. With more than 50 workbooks containing references, that's a bit of a pain, but then this whole thing has been a pain. Since last looking at your response, I have discovered that I can open each workbook, click Edit Links when prompted, select the UDF workbook, click Change Source, browse to and select my xlam file, click Update Values, and save the workbook. That too eliminates the qualified function references. Fingers crossed this problem doesn't come back again.

    There seems to be no doubt that Excel or some other part of Windows is storing some value that keeps it from automatically picking up the most recent version each time. Who knows where that might be or how to overcome it (if that's even possible).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Locked formula changes reference when rows added to reference sheet in same workbook
    By macrorookie in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-19-2014, 04:08 PM
  2. Trying to create a cross reference sheet within a workbook
    By electromech in forum Excel General
    Replies: 5
    Last Post: 02-13-2014, 08:59 PM
  3. [SOLVED] Create new workbook, then REFERENCE it, Excel 2013
    By rbrian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-02-2013, 09:09 AM
  4. Replies: 0
    Last Post: 09-23-2013, 05:59 PM
  5. [SOLVED] copy active sheet, create new workbook, name new workbook based on cell reference
    By jm0392 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-20-2012, 07:12 PM
  6. Replies: 0
    Last Post: 12-09-2008, 06:13 PM
  7. Create a workbook reference
    By nicolachen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-21-2007, 05:09 PM
  8. Replies: 0
    Last Post: 08-04-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1