ryancgarrett
Board Regular
- Joined
- Jun 18, 2011
- Messages
- 122
I have a large data set with dates in column A, and alphanumeric strings in column B. I need to count the unique values in Column B between two dates in Column A. I've tried a few solutions, but due to the data size standard array formulas were freezing my workbook for 5-10 minutes. I found the following VBA formula which works great, but need to edit it to allow for the data criteria:
Code:
Function CountUnique(ListRange As Range) As IntegerDim CellValue As Variant
Dim UniqueValues As New Collection
Application.Volatile
On Error Resume Next
For Each CellValue In ListRange
UniqueValues.Add CellValue, CStr(CellValue) ' add the unique item
Next
CountUnique = UniqueValues.Count
End Function