Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2006

Tip: Looking for answers? Try searching our database.

User defined function gives #NAME?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Wirtr - 21 Sep 2006 22:19 GMT
I've writtena User Defined Function that yields #NAME? when I use it in a
spread sheet. Why is this?  The code for the function is below.

The code is in a module in PERSONAL.xls.  I have also tried it in a module
in the workbook where it is used. Same result.

This UDF used to work for me. What am I doing wrong?

John Wirt

Function SigTest(cell1, cell2, cell3, cell4)
   Dim testval As Long
   testval = (cell1 - cell2) * (cell1 - cell2)
   testval = testval / (cell3 * cell3 + cell4 * cell4)
If testval > 3.841447 Then
   SigTest = "*"
Else
   SigTest = ""
End If
End Function
Bob Phillips - 21 Sep 2006 22:26 GMT
Try using

Personal.xls!SigTest(cell1, cell2, cell3, cell4)

in the worksheet

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> I've writtena User Defined Function that yields #NAME? when I use it in a
> spread sheet. Why is this?  The code for the function is below.
[quoted text clipped - 16 lines]
> End If
> End Function
JMB - 21 Sep 2006 22:34 GMT
To call it from Personal.xls, try

=Personal.xls!Sigtest(cell1, cell2, cell3, cell4)

> I've writtena User Defined Function that yields #NAME? when I use it in a
> spread sheet. Why is this?  The code for the function is below.
[quoted text clipped - 16 lines]
> End If
> End Function
Jim Thomlinson - 21 Sep 2006 22:35 GMT
Not too sure. It worked for me. I did clean it up a bit but the gist of it is
the same...

Function SigTest(cell1 As Range, cell2 As Range, cell3 As Range, cell4 As
Range) As String
   If (cell1 - cell2) ^ 2 / (cell3 ^ 2 + cell4 ^ 2) > 3.841447 Then
       SigTest = "*"
   Else
       SigTest = ""
   End If
End Function

I am assuming that the functions is stored in a regular code module and not
a sheet or thisworkbook. If so then that would be the culprit...
Signature

HTH...

Jim Thomlinson

> I've writtena User Defined Function that yields #NAME? when I use it in a
> spread sheet. Why is this?  The code for the function is below.
[quoted text clipped - 16 lines]
> End If
> End Function
tplourde - 22 Sep 2006 00:04 GMT
Or consider skipping the function and use the following formula in you
worksheet.

Assume cells 1,2,3,4 are C1,D1,E1,F1 and the formula would look like:

=IF((C1-D1)^2/(E1^2+F1^2)>3.841447,"Happy","Sad")

> I've writtena User Defined Function that yields #NAME? when I use it in a
> spread sheet. Why is this?  The code for the function is below.
[quoted text clipped - 16 lines]
> End If
> End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.