Results 1 to 4 of 4

Thread: Summarize Data from Dates to Months based on Criteria

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    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
    Last edited by DocAElstein; 01-02-2022 at 05:28 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. Replies: 19
    Last Post: 02-14-2019, 11:53 PM
  2. Copy paste data based on criteria
    By analyst in forum Excel Help
    Replies: 7
    Last Post: 01-13-2014, 12:46 PM
  3. Summing Data based on certain criteria
    By Howardc in forum Excel Help
    Replies: 7
    Last Post: 01-30-2013, 07:12 PM
  4. The Number of Years, Months and Days Between Two Dates
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 7
    Last Post: 06-08-2012, 10:35 PM
  5. Split data based on criteria
    By Mahesh.sreekakulam in forum Excel Help
    Replies: 3
    Last Post: 06-08-2012, 09:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •