Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User defined function gives #NAME?

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default User defined function gives #NAME?

To call it from Personal.xls, try

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


"John Wirtr" wrote:

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default User defined function gives #NAME?

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

Jim Thomlinson


"John Wirtr" wrote:

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default User defined function gives #NAME?

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")

"John Wirtr" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined Function Barb Reinhardt Excel Worksheet Functions 3 March 28th 07 02:23 AM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 01:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"