Hindi-Tech : Count unique values in a range in excel using VBA Code
Press Alt + F11 key on the Excel, this will open the VBA window.
On the VBA Window, right-click over the ‘Microsoft Excel Objects’ > ‘Insert’ > ‘Module’.
=COUNTUNIQUE(A1:A10,FALSE/TRUE)
VBA CODE👇👇
[Function COUNTUNIQUE(DataRange As Range, CountBlanks As Boolean) As IntegerDim CellContent As VariantDim UniqueValues As New CollectionApplication.VolatileOn Error Resume NextFor Each CellContent In DataRangeIf CountBlanks = True Or IsEmpty(CellContent) = False ThenUniqueValues.Add CellContent, CStr(CellContent)End IfNextCOUNTUNIQUE = UniqueValues.CountEnd Function]
[contact]