Advertisement
YasserKhalil2019

T3788_SUM TOTAL Unique Dates By Dictionary

Aug 24th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. https://excel-egy.com/forum/t3788
  2. ---------------------------------
  3.  
  4. Sub SUM_TOTAL_Unqiue_Dates_By_Dictionary()
  5. Dim a, dic As Object, d As Date, i As Long
  6.  
  7. Application.ScreenUpdating = False
  8. With Worksheets(1)
  9. a = .Range("G2:I" & .Cells(Rows.Count, 9).End(xlUp).Row).Value
  10. Set dic = CreateObject("Scripting.Dictionary")
  11.  
  12. For i = LBound(a, 1) To UBound(a, 1)
  13. If Not IsEmpty(a(i, 3)) Then
  14. d = DateValue(Replace(Split(a(i, 3))(0), ".", "/"))
  15. If Not dic.Exists(d) Then dic(d) = Array(, 0)
  16. dic(d) = Array(d, dic(d)(1) + Val(a(i, 1)))
  17. End If
  18. Next i
  19.  
  20. .Range("S2").Resize(dic.Count, 2).Value = Application.Transpose(Application.Transpose(dic.items))
  21. With .Range("P3:P33")
  22. .Formula = "=IFERROR(INDEX(T:T,MATCH(O3,S:S,0)),"""")"
  23. .Value = .Value
  24. End With
  25. .Columns("S:T").Clear
  26. End With
  27. Application.ScreenUpdating = True
  28. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement