Sub GenerateSummary()
Dim wsTasks As Worksheet, wsSummary As Worksheet
Dim lastRow As Long, i As Long
Dim employeeDict As Object
Dim employee As String
Dim completed As Long, total As Long
Set wsTasks = ThisWorkbook.Sheets("Tasks")
Set wsSummary = ThisWorkbook.Sheets("Summary")
Set employeeDict = CreateObject("Scripting.Dictionary")
' Görev tablosundaki tüm çalışanları ve durumları al
lastRow = wsTasks.Cells(wsTasks.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow
employee = wsTasks.Cells(i, 2).Value
If Not employeeDict.exists(employee) Then
employeeDict.Add employee, Array(0, 0) ' [Tamamlanan, Toplam]
End If
total = employeeDict(employee)(1) + 1
completed = employeeDict(employee)(0)
If wsTasks.Cells(i, 6).Value = "Tamamlandı" Then completed = completed + 1
employeeDict(employee) = Array(completed, total)
Next i
' Özet sayfasını temizle
wsSummary.Cells.Clear
wsSummary.Cells(1, 1).Value = "Çalışan"
wsSummary.Cells(1, 2).Value = "Tamamlanan Görevler"
wsSummary.Cells(1, 3).Value = "Toplam Görevler"
wsSummary.Cells(1, 4).Value = "Tamamlama Yüzdesi"
' Verileri özet sayfasına yaz
Dim rowIndex As Long
rowIndex = 2
For Each employee In employeeDict.Keys
wsSummary.Cells(rowIndex, 1).Value = employee
wsSummary.Cells(rowIndex, 2).Value = employeeDict(employee)(0)
wsSummary.Cells(rowIndex, 3).Value = employeeDict(employee)(1)
wsSummary.Cells(rowIndex, 4).Value = Format((employeeDict(employee)(0) / employeeDict(employee)(1)) * 100, "0.00") & "%"
rowIndex = rowIndex + 1
Next employee
MsgBox "Görev özeti başarıyla oluşturuldu!", vbInformation
End Sub