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:-
So - erm - why does it not work ???Public Function RadFromArea(Area As Double) As Double RadFromArea = Sqr(Area / Pi) End Function
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.
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
If you must use your UDF, change it to:
Public Function RadFromArea(Area As Double) As Double RadFromArea = Sqr(Area / WorksheetFunction.Pi) End Function
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 !
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
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 !?!?!?!![]()
Last edited by RobinClay; 11-18-2011 at 08:00 PM. Reason: To attach File
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks