CountDiff VBA

TeeMar

New Member
Joined
Oct 28, 2002
Messages
23
Does anyone know the VBA code for the Morefunc addin for "CountDiff"

I just love this add-in! but would like to put the vba code in a few sheets that are shared with folks that do not have Countdiff but need to alter the sheet.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Sorry, but they'd need to have the MOREFUNC Add-In as well, unless you want to recreate Laurent's code.

Smitty
 
Upvote 0
I think I found a VBA that works similar to COUNTDIFF:

The custom function below counts the unique values only from a given range.

This function uses the fact that a collection can only hold items with unique identifications keys.

If you try to add an item with a key that already exists in the collection, an error will occur.

Function CountUniqueValues(InputRange As Range) As Long
Dim cl As Range, UniqueValues As New Collection
Application.Volatile
On Error Resume Next ' ignore any errors
For Each cl In InputRange
UniqueValues.Add cl.Value, CStr(cl.Value) ' add the unique item
Next cl
On Error GoTo 0
CountUniqueValues = UniqueValues.Count
End Function



Example:
=CountUniqueValues(A1:A100) will count the unique values in the range A1:A100
 
Upvote 0

Forum statistics

Threads
1,215,892
Messages
6,127,611
Members
449,389
Latest member
ChessManNaill

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top