Guest User

Untitled

a guest
Jun 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. '============================================================================================
  2. ' Module : <any standard module>
  3. ' Version : 0.1.1
  4. ' Part : 1 of 1
  5. ' References : (Optional) Microsoft Scripting Runtime [Scripting]
  6. ' Source : https://superuser.com/a/1332369/763880
  7. '============================================================================================
  8. Option Explicit
  9.  
  10. Public Function CountDistintMultiSelections _
  11. ( _
  12. count_array As Range _
  13. ) _
  14. As Long
  15.  
  16. Dim dictSelections As Object '##Early Bound## As Scripting.Dictionary
  17. Set dictSelections = CreateObject("Scripting.Dictionary") '##Early Bound## = New Dictionary
  18.  
  19. Dim celCell As Range
  20. For Each celCell In Intersect(count_array, count_array.Parent.UsedRange)
  21. Dim varSelections As Variant
  22. varSelections = Split(celCell.Value2, ", ")
  23. Dim varSelection As Variant
  24. For Each varSelection In varSelections
  25. If dictSelections.Exists(varSelection) Then
  26. dictSelections(varSelection) = dictSelections(varSelection) + 1
  27. Else
  28. dictSelections.Add varSelection, 1
  29. End If
  30. Next varSelection
  31. Next celCell
  32. CountDistintMultiSelections = dictSelections.Count
  33.  
  34. End Function
Add Comment
Please, Sign In to add comment