Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '============================================================================================
- ' Module : <any standard module>
- ' Version : 0.1.1
- ' Part : 1 of 1
- ' References : (Optional) Microsoft Scripting Runtime [Scripting]
- ' Source : https://superuser.com/a/1332369/763880
- '============================================================================================
- Option Explicit
- Public Function CountDistintMultiSelections _
- ( _
- count_array As Range _
- ) _
- As Long
- Dim dictSelections As Object '##Early Bound## As Scripting.Dictionary
- Set dictSelections = CreateObject("Scripting.Dictionary") '##Early Bound## = New Dictionary
- Dim celCell As Range
- For Each celCell In Intersect(count_array, count_array.Parent.UsedRange)
- Dim varSelections As Variant
- varSelections = Split(celCell.Value2, ", ")
- Dim varSelection As Variant
- For Each varSelection In varSelections
- If dictSelections.Exists(varSelection) Then
- dictSelections(varSelection) = dictSelections(varSelection) + 1
- Else
- dictSelections.Add varSelection, 1
- End If
- Next varSelection
- Next celCell
- CountDistintMultiSelections = dictSelections.Count
- End Function
Add Comment
Please, Sign In to add comment