
Untitled
By: a guest on
Jul 1st, 2012 | syntax:
None | size: 1.20 KB | hits: 14 | expires: Never
find unique dates in excel vba array
_Here is my dataset:_
12/07/2010 3.5
12/07/2010 2.1
12/07/2010 2.2
12/08/2010 5.2
12/08/2010 3.2
12/09/2010 4.7
12/07/2010
12/08/2010
12/09/2010
Sub Uniques()
Dim oColl As New Collection
Dim vArr As Variant
Dim vItem As Variant
Dim j As Long
vArr = Range("A1:B6")
On Error Resume Next
For j = LBound(vArr) To UBound(vArr)
oColl.Add vArr(j, 1), CStr(vArr(j, 1))
Next j
On Error GoTo 0
For Each vItem In oColl
Debug.Print vItem
Next vItem
End Sub
Sub test()
Dim vItem As Variant
Dim vArray(5) As Variant
vArray(0) = CDate("12/07/2010")
vArray(1) = CDate("12/07/2010")
vArray(2) = CDate("12/07/2010")
vArray(3) = CDate("12/08/2010")
vArray(4) = CDate("12/08/2010")
vArray(5) = CDate("12/09/2010")
Dim colDates As Collection
Set colDates = New Collection
On Error Resume Next
For Each vItem In vArray
colDates.Add vItem, CStr(vItem)
Next vItem
End Sub
arTargetArray as Array
For each Item in your_array
value = Filter(arTargetArray, Item)
if value null
add item to arTargetArray.
end if
next each