I have two columns of dates up to 30k lines. I want to filter for one date in the second column and return all the unique dates from the first column.
I could build this in Access but I don't use Access for anything else so it seems overkill to use that. And partly because I am curious if I can do it in Excel. I'd prefer not to use a loop because it will be expensive in terms of time to run and I am just learning about arrays and class modules so this is a great example.
There is some background on this already on SOF but it's not detailed enough for me - I'm unfamiliar with Class Modules Filtering 2D Arrays in Excel VBA
Any help or pointers would be greatly appreciated.
Sub CreateUniqueTradeDatesForAsOfDate_test()
Dim InternalArray As Variant
Dim Rg_Internal As Range
Dim arr As New Collection
Dim myRow As Long
Dim myCol As Long
Set d = CreateObject("Scripting.Dictionary")
'set the range
Set Rg_Internal = Worksheets("Bloomberg").Range("G:H")
'Set the array to the range
InternalArray = Rg_Internal.Value
'Transpose the array
InternalArray = Application.Transpose(InternalArray)
'Create the unique
With CreateObject("scripting.dictionary")
For Each it In InternalArray
d = .Item(it)
Next
d = .Keys ' the array .keys contains all unique keys
End With
'print to the immediate window but all unique values of the array
' not just the unique values from the first column based on
'the criteria from the second column
For Each i In d 'To UBound(10, 1)
Debug.Print i; RowNos
Next i
End Sub