+ Reply to Thread
Results 1 to 12 of 12

#name? error when I attempt to use a newly defined UDF

  1. #1
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    #name? error when I attempt to use a newly defined UDF

    I have a UDF which I know works while in debug mode in the VBA environment. the function did not access the worksheet but used test data that emulated the cases I expected to see.

    Now I wish to use my function in my worksheet.

    I get the "#name?" error when i attempt to run the UDF

    Here are some hints at what is happening.
    the workbook is macro enabled (file->options -> trust center -> settings -> enabled all macros

    if i get out of the vba environment and into excel, and select macros, and select the workbook in which the macro exists, no macros are seen. blank box.

    If i go to a worksheet cell and type an "=" sign and then begin typing my UDF, a drop down list box
    appears with my UDF listed. I dbl click on it excel finishes the udf name afterwhich I put the parameters into my UDF.

    upon hitting return, I get the #name? error

    I do not know where to turn to trouble shoot. I did try inserting a new module and looked for where the environment
    placed the module. the new module was placed in the vba project on the same level as my UDF and on the same level as sheet1 etc. i am assuming it is in the correct place.

    Soooo while the UDF DOES appear as i begin typing it as one of many functions available, when I input data it throws the error #name?

    a long shot....desparate...some time ago...i tried putting the macro in personal.xlsb and attached the name to the udf name. the macro worked.

    but i don't want to put it in personal.xlsb until I get it working in the workbook in which the UDF was written.

    please help

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,012

    Re: #name? error when I attempt to use a newly defined UDF

    Attach your workbook for review.

  3. #3
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Re: #name? error when I attempt to use a newly defined UDF

    I would love to post my workbook for review....but for some reason i do not see how to do it. Sorry....I must be blind.
    if you know how, please help me. I desparetely want to get over this hurdle and charge onwards in a productive manner.
    bil

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: #name? error when I attempt to use a newly defined UDF

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    HTH
    Regards, Jeff

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: #name? error when I attempt to use a newly defined UDF

    Where is the code for he UDF located and what's the name of the UDF?
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Re: #name? error when I attempt to use a newly defined UDF

    It appears to be suddenly working, though i can not see the udf in the macro menu

    the important parts of the workbook"

    FieldData worksheet.....R4c6:r11c9 (columns titled "DMS", "d", "m", "s"

    and Module_DMS
    Attached Files Attached Files

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: #name? error when I attempt to use a newly defined UDF

    Is the UDF now working as you wanted/expected it to?

    PS You won't see a function in the macro menu because, well, it's not a macro.

  8. #8
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: #name? error when I attempt to use a newly defined UDF

    Are you sure you don't want to take the opportunity to simplify everything you are doing here?
    Is it that you want to convert DDD.MMSS into a number in days with decimals (and an error check)? If so you seem to be jumping through a lot of hoops with comments to do so.

    maybe this would be close to what you would want - might not even need the 0 adding part

    Please Login or Register  to view this content.
    Last edited by scottiex; 04-18-2017 at 04:35 AM.

  9. #9
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Re: #name? error when I attempt to use a newly defined UDF

    Scottiex,

    Thank you for responding. I do appreciate your wonderfully clear code.

    Please check back. I need a small amount of time to go through your code to make sure i understand it.
    and test it out.

    Please understand that I do very much appreciate the valuable time and effort you invested in my problem.
    bil

  10. #10
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Re: #name? error when I attempt to use a newly defined UDF

    love the clarity and simplicity of your code. I tried it out and it
    works beautifully.


    I have a few questions that will help me understand a few things

    (1) The function, Deci returns a string. I am assuming it is because you can
    return an error message as well as a character number.

    i believe I need to return the unpacked decimal number as type double
    I am saying that because I will want to use the decimal data in later
    calculations.

    Knowing that should Deci return data of type double?
    How do i reveal error messages? through a msgbox?


    I may be misunderstanding something. In fact, all numbers seen in the
    worksheet are actually strings (ascii characters) but their storage is
    dependent upon the data type defined in excel format? What I am getting
    at is that i have no idea whether to return strings or numbers to a cell
    in a worksheet. is the answer dependent on use?

    ie: if i am later going to use an excel function, "sum" then I had better
    return a "number" but if i am not going to mathematically do anything with the
    returned data do i return it ias a string?

    (2) Why did you chose to input DMS as a variant and not as a double?
    I guess I don't understand when to use a variant and when to be
    specific.

    (3) "Mid" and "left" functions are string operators. Yet is not DMS a string?
    (4) "Mid" and "left" functions return a string and yet you defined
    Deg is an integer (why an integer?)
    Min as a Double (why double? because of binary conversion?)
    Sec as a Double (why double? because of binary conversion?)

  11. #11
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: #name? error when I attempt to use a newly defined UDF

    I'm not sure my usage is entirely optimal but

    Deg, min and sec had to be added together so they have to be treated as numbers at some point.
    Deg can only be an integer number so no need for double.
    min and sec however were numbers with lots of decimals so I used double.

    yes Deci is a string so I can hand the error message - It seems pretty non-standard to have a function call message box, i suppose more standard is for it to would work like most functions and just error if the data is invalid. But i noticed the code had gone to the effort of being clear in this space.

    But you can change the data type if needed. eg

    https://msdn.microsoft.com/en-us/library/s2dy91zy.aspx

  12. #12
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    178

    Re: #name? error when I attempt to use a newly defined UDF

    Thank you Scottiex for your help and your time. Most generous.

    Have a wonderful day....

+ 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] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  5. [SOLVED] How do I apply globally defined names to newly inserted templates?
    By Manzomanen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2012, 07:23 AM
  6. [SOLVED] Run Time 1004 - App Defined or Object defined error with String defined path structure
    By sarails in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2012, 09:38 PM

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