'DisplayArrayDupeCount.vbs 'This scriptlet counts and displays duplicate items in a single dimension Array 'and displays the results 'alan dot kaplan at va gov '2-15-13 Option Explicit 'Example large array Dim aDates aDates = Array("2/11/2013 11:10","2/11/2013 11:10","2/10/2013 10:59","2/11/2013 11:10", _ "2/11/2013 11:10","11/13/2012 12:52","2/11/2013 11:10","2/11/2013 11:10","2/11/2013 11:10", _ "2/8/2013 21:23","2/11/2013 11:10","11/13/2012 12:29","2/11/2013 16:51","2/11/2013 11:10", _ "2/11/2013 11:10","2/11/2013 11:10","2/10/2013 10:59","11/12/2012 20:51") DisplayArrayDupeCount aDates,1 Sub DisplayArrayDupeCount(aTemp, iShow) 'iShow is threshold to display, typically 0 or 1 Dim itemNameKey Dim d:Set d = GetDupDict(aTemp) For Each itemNameKey In d.Keys If d(itemNameKey) > iShow Then WScript.Echo itemNameKey & " found in array " & d(itemNameKey) & " times" End If Next Set d = Nothing End Sub Function GetDupDict(aTemp) Dim dItems, j 'Create a Dictionary Set dItems = CreateObject("Scripting.Dictionary") For j = 0 To UBound(aTemp) If Not IsEmpty(aTemp(j)) Then 'dItems.Add aTemp(j),dItems(aTemp(j)) + 1 fails 'unlike using .Add, the below syntax allows you to reuse keys dItems(aTemp(j)) = dItems(aTemp(j)) + 1 End If Next Set GetDupDict = dItems Set dItems = Nothing End Function