willastrowalker
New Member
- Joined
- Aug 28, 2015
- Messages
- 9
Hello,
I am trying to count unique cells in a filtered list. The macro I have to count total unique cells seems to work perfectly. but i'm trying to change it in two ways.. First is to have it count the unique cells that are not filtered/visible (visibility is set my filters, not group & hide).
the next way i'm trying to do it it to make it a countuniqueif function.. eg, =Countuniqueif(a1:a100,b1:b100,"Countme") - column A has potentially unique values, column B has the "Countme" tag.
Any ideas on either would be a huge help!
thanks
I am trying to count unique cells in a filtered list. The macro I have to count total unique cells seems to work perfectly. but i'm trying to change it in two ways.. First is to have it count the unique cells that are not filtered/visible (visibility is set my filters, not group & hide).
the next way i'm trying to do it it to make it a countuniqueif function.. eg, =Countuniqueif(a1:a100,b1:b100,"Countme") - column A has potentially unique values, column B has the "Countme" tag.
Any ideas on either would be a huge help!
thanks
Code:
Function CountUnique(ListRange As Range) As Integer
Dim 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