+ Reply to Thread
Results 1 to 6 of 6

Thread: #NAME? error

  1. #1
    Registered User
    Join Date
    11-18-2011
    Location
    Dorset
    MS-Off Ver
    Excel 2003
    Posts
    3

    #NAME? error

    Well ! It worked just FINE yesterday !

    It's a simple little thing:-

    .........G............................H
    16......Height.......................54
    17......Width......................110
    18.......Area.....................5940...............Formula is =H16*H17
    19....Perimeter...................328...............Formula is =H16+H16+H17+H17
    20..Equiv diameter.......#NAME?...........Formula is =2*RadFromArea(H18)


    AND then I have the UDF:-

    Public Function RadFromArea(Area As Double) As Double
    RadFromArea = Sqr(Area / Pi)
    End Function
    So - erm - why does it not work ???

    It doesn't even TRY to run the UDF, which compiled OK

    ALL the other similar UDFs work fine...
    Last edited by Paul; 11-18-2011 at 02:16 PM. Reason: Added CODE tags for user. Please do so yourself in the future.

  2. #2
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: #NAME? error in Excel 2010 SP1

    Why build a UDF when Excel has functions that can handle that:

    =2*SQRT(H18/PI())
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: #NAME? error in Excel 2010 SP1

    If you must use your UDF, change it to:
    Public Function RadFromArea(Area As Double) As Double
    RadFromArea = Sqr(Area / WorksheetFunction.Pi)
    End Function

  4. #4
    Registered User
    Join Date
    11-18-2011
    Location
    Dorset
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: #NAME? error

    Thank you both - but neither answers the question.

    Sorry - I forgot to mention that I have already defined Pi as a constant elsewhere.

    Excel doesn't even try to run the UDF, so it matters not what is there. It does compile OK.

    WHY does it not run.... Yet it did yesterday !

  5. #5
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,772

    Re: #NAME? error

    Works fine for me.

    Where is the code? It has to be in a standard module in the workbook where the formulas appear, or in a workbook referenced by the workbook with the formulas.

    EDIT: And macros have to be enabled.
    Last edited by shg; 11-18-2011 at 07:35 PM.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    11-18-2011
    Location
    Dorset
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: #NAME? error

    Thank you also for that response.

    It gets worse !

    That formula appears in two other places, and works fine, and in two more where it also doesn't work !

    If I copy one of the workingones, it works. If I copy a non-working one, it doesn't.

    So I copied a working one into that slot, and Voila ! It works !

    It's a mystery....


    Oh - the routine is in an add-in Library with several hundred UDFs - and, yes, micros are enabled, and the add-in is referenced. And it works elsewhere !?!?!?!
    Attached Files Attached Files
    Last edited by RobinClay; 11-18-2011 at 08:00 PM. Reason: To attach File

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0