I can see several problems:
There is no connection between the rng1 and rng2 input parameters and the
string rng1,rng2 in evaluate which will be looking for excel defined named
ranges called rng1 and rng2
if you solve this problem you wont need the Application.volatile
Application.evaluate always assumes that that unqualified range references
refer to the active sheet, so your function would not work unless both rng1
and rng2 happen to be sitting on the active sheet.
You should add an on error handler to trap Evalute errors
see
http://www.decisionmodels.com/calcsecretsh.htm for discussion of how to
use evaluate and an example UDF
regards
Charles
______________________
Decision Models
FastExcel 2.2 Beta now available
www.DecisionModels.com
"Myles" wrote in
message ...
Can anyone tell me why the following function to test the uniqueness of
values in a (single and same) range fails to fire? It's based on the
Worksheet Array formula *=MAX(COUNTIF(rng,rng)) *returning 1 for
"unique", otherwise "not unique".
Function UniqueTest(rng1 As Range, rng2 As Range) As String
Application.Volatile
x = Application.Evaluate("Max(Countif(rng1,rng2))")
If x = 1 Then
UniqueTest = "Unique"
Else
UniqueTest = "Not Unique"
End If
End Function
and neither does ...
Function UniqueTest2(rng1 As Range, rng2 As Range) As String
Application.Volatile
x = [Max(Countif(rng1,rng2))]
If x = 1 Then
UniqueTest2 = "Unique"
Else
UniqueTest2 = "Not Unique"
End If
End Function
TIA
Myles
--
Myles
------------------------------------------------------------------------
Myles's Profile:
http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=522993