#1   Report Post  
John Wirt
 
Posts: n/a
Default Why #NAME?

Here is a simple user-defined function. It is the basic test for statistical
significance.

When I insert this code in a module in PERSONAL.XLS and use it in a cell in
an open workbook, I get the error message: #NAME?

If I insert this function in a module of the open workbook, it works.

Why doesn't this UDF work when inserted in PERSONAL.XLS?

Thank you.

John Wirt
---

Public 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


  #2   Report Post  
David McRitchie
 
Posts: n/a
Default

Hi John,

use =personal.xls!SigTest(....)

You might want to give your parameters more descriptive
names than cell1, cell2, cell3, cell4 as they are your documentation
as to what is needed
for each parameter without going to great lengths.

Macros are found from open workbooks, but not user defined functions.

If that is not acceptable you can create a Reference in your VBE
http://www.mvps.org/dmcritchie/excel/install.htm
but I did that in the past and it got me into trouble. Can't remember
what that problem was though.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"John Wirt" wrote in message ...
Here is a simple user-defined function. It is the basic test for statistical
significance.

When I insert this code in a module in PERSONAL.XLS and use it in a cell in
an open workbook, I get the error message: #NAME?

If I insert this function in a module of the open workbook, it works.

Why doesn't this UDF work when inserted in PERSONAL.XLS?

Thank you.

John Wirt
---

Public 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  
 
Posts: n/a
Default

Thanks, David. An Add-in looks like a good solution. Your web pages are
great. Glad to find them.
Yes, I'll change the cell1, cell2. John

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



All times are GMT +1. The time now is 01:18 PM.

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"