Microsoft? Excel? for Microsoft 365 MSO (Version 2307 Build 16.0.16626.20170) 64-bit
Posts
14
Search through data, filter based on criteria and count the values paste to new sheet
Dear Experts,
I have more than 5000 rows of datas from which, I need to extract the total number of "Resolved" cases based on few criteria, copy them and paste it in another sheet Summary with respective headers and Rows.
From the Master data, search respective
"Technician's Name" and filter by "Case Type" which should be only "Breakdown" "Preventive Maintenance",
then by "Category" number of "AC" and "Non AC",
Next by (Count) Case Stage "Resolved" "Delivered"
"Day wise" paste the total count in "Summary" Sheet having Row header with "Technician's Name", "Date" and Column headers "Resolved (AC),Resolved (Non AC), Delivered (AC)
and Delivered (Non AC)
Need the total count of Cases attended by each technician against every Category.
Attached Sample workbook. Please help solution through VBA
Re: Search through data, filter based on criteria and count the values paste to new sheet
Try below code.
PHP Code:
Option Explicit Sub summary() Dim lr&, i&, j&, rng, res(), pos&, sp, s Dim dic As Object, item Set dic = CreateObject("Scripting.Dictionary") With Sheets("Dump") lr = .Cells(Rows.Count, "A").End(xlUp).Row rng = .Range("E2:R" & lr).Value End With For i = 1 To UBound(rng) pos = IIf(rng(i, 14) = "Resolved", 1, IIf(rng(i, 14) = "Delivered", 3, 0)) If pos > 0 Then pos = pos + IIf(rng(i, 7) = "AC", 0, 1) If Not dic.exists(rng(i, 1)) Then Select Case pos Case 1 s = "1-0-0-0" Case 2 s = "0-1-0-0" Case 3 s = "0-0-1-0" Case 4 s = "0-0-0-1" End Select dic.Add rng(i, 1), s Else sp = Split(dic(rng(i, 1)), "-") sp(pos - 1) = sp(pos - 1) + 1 dic(rng(i, 1)) = Join(sp, "-") End If End If Next Sheets("Summary").Activate ReDim res(1 To dic.Count, 1 To 4): i = 0 For Each item In dic.items i = i + 1 For j = 1 To UBound(res, 2) res(i, j) = Split(item, "-")(j - 1) Next Next Range("A2:A1000,D2:G1000").ClearContents Range("A2").Resize(dic.Count, 1).Value = WorksheetFunction.Transpose(dic.keys) Range("D2").Resize(UBound(res), UBound(res, 2)).Value = res End Sub
Bookmarks