A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi Jim,
The function that you are using cannot be used as an Excel worksheet function as the code requires the selection of cells which is not legitimate in the case of a UDF (User Defined Function).
Whilst you could rewrite the function to remove such cell selections, I would suggest that a much better alternative would be to use the following function written by Charles Williams:
'=========>>
Public Function COUNTU(theRange As Range) As Variant
'--------------------------------------------------------------
' Author : Charles Williams, Decision Models Limited
' Link : **http://msdn.microsoft.com/en-us/library/ff700515(v=office.14).aspx**
' Purpose : Count unique values
'-------------------------------------------------------------
Dim colUniques As New Collection
Dim vArr As Variant
Dim vCell As Variant
Dim vLcell As Variant
Dim oRng As Range
Dim bCount As Boolean
Set oRng = Intersect(theRange, theRange.Parent.UsedRange)
vArr = oRng
On Error Resume Next
For Each vCell In vArr
If vCell <> vLcell Then
If Len(CStr(vCell)) > 0 Then
colUniques.Add vCell, CStr(vCell)
End If
End If
vLcell = vCell
Next vCell
COUNTU = colUniques.Count
End Function
'<<=========
===
Regards,
Norman