[COLOR="Navy"]Sub[/COLOR] MG28Feb18
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range, Rng [COLOR="Navy"]As[/COLOR] Range, Col [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] nRng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dic [COLOR="Navy"]As[/COLOR] Object, Dt [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] Q
Col = Array(1, 3, 5)
[COLOR="Navy"]With[/COLOR] Sheets("Sheet1")
[COLOR="Navy"]Set[/COLOR] Rng = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Set[/COLOR] Dic = CreateObject("Scripting.Dictionary")
Dic.CompareMode = 1
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dt [COLOR="Navy"]In[/COLOR] Col
[COLOR="Navy"]Set[/COLOR] Rng = Range(Cells(1, Dt), Cells(Rows.Count, Dt).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]If[/COLOR] Not Dic.exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]Set[/COLOR] Dic(Dn.Value) = CreateObject("Scripting.Dictionary")
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]If[/COLOR] Not Dic(Dn.Value).exists(Dn.Row) [COLOR="Navy"]Then[/COLOR]
Dic(Dn.Value).Add (Dn.Row), Nothing
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]Next[/COLOR] Dt
[COLOR="Navy"]Dim[/COLOR] k [COLOR="Navy"]As[/COLOR] Variant, nDt [COLOR="Navy"]As[/COLOR] Date, Ldt [COLOR="Navy"]As[/COLOR] Date, p [COLOR="Navy"]As[/COLOR] Variant, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
c = 1
[COLOR="Navy"]With[/COLOR] Sheets("Sheet2")
[COLOR="Navy"]If[/COLOR] .TextBox1.Value <> "" And .TextBox2.Value <> "" [COLOR="Navy"]Then[/COLOR]
.Columns("A:B").ClearContents
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] k [COLOR="Navy"]In[/COLOR] Dic.Keys
[COLOR="Navy"]If[/COLOR] Dic.exists(CDate(.TextBox1.Value)) And Dic.exists(CDate(.TextBox2.Value)) [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] k >= CDate(.TextBox1.Value) And k <= CDate(.TextBox2.Value) [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] p [COLOR="Navy"]In[/COLOR] Dic(k)
c = c + 1
.Cells(c, "a") = k
.Cells(c, "b") = p
[COLOR="Navy"]Next[/COLOR] p
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]ElseIf[/COLOR] Dic.exists(CDate(.TextBox1.Text)) [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] k >= CDate(.TextBox1.Text) [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] p [COLOR="Navy"]In[/COLOR] Dic(k)
c = c + 1
.Cells(c, "a") = k
.Cells(c, "b") = p
[COLOR="Navy"]Next[/COLOR] p
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] k
.Range("A1:B1").Value = Array("Date", "Row No")
.Cells(2, 1).Resize(c, 2).Sort .Cells(2, 1)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]