Hi Siyab, Happy New Year too
I personally prefer to avoid using Excel’s built in date things if possible, and that seems simple to do here, even if it may not result in the best most efficient coding.
Having said that it’s more normal and professional to handle the thing with Excel’s built in date things.
But I am not doing that in this example.
I am doing in this example the simplest and probably most inefficient worksheets interaction type coding
The macro below does a very simple text comparison for the specific sample you gave .
I have not made the macro dynamic: I have shown you in other of your Threads how to do that. ( Lr stuff etc. )
Code:Sub SummarizeDatafromDatestoMonthsbasedonCriteria() ' https://excelfox.com/forum/showthread.php/2774-Summarize-Data-from-Dates-to-Months-based-on-Criteria Rem 0 Worksheets info Dim WsCT As Worksheet, WsS As Worksheet Set WsCT = ThisWorkbook.Worksheets("Case Tracker"): Set WsS = ThisWorkbook.Worksheets("Summary") Rem 1 Simple worksheet solution loop in a loop in a loop Dim rCT As Long, rS As Long, cS As Long For rS = 3 To 19 Step 1 ' _ === Loop rows in summary ============ For rCT = 3 To 12 Step 1 ' Loop rows in Case Tracker data '------ If Mid(WsCT.Range("B" & rCT & "").Text, 4) = WsS.Range("B" & rS & "").Text Then ' this is checking for a month matsch in the columns B of the worksheets For cS = 3 To 6 Step 1 ' loop columns in Summary '############### If WsCT.Range("D" & rCT & "").Value2 = WsS.Cells(2, cS).Value2 Then ' this checks for match in progress Let WsS.Cells(rS, cS).Value = WsS.Cells(rS, cS).Value + 1 Else End If Next cS ' ####################################################### Else End If Next rCT ' ------------------------------------------------------ Next rS ' _ ===================================================== End Sub
results after running macro here https://excelfox.com/forum/showthrea...ll=1#post16305
I am not intending to give you the best efficient coding here. It’s intended to share some ideas.
( Of course, as ever, anyone else is welcome to add an alternative solution for you, even I might do another if I feel like it, for my own amusement later )
Alan





Reply With Quote
Bookmarks