Ekran Resmi 2024-01-02 17.32.53.png
Bu liste girildikten sonra başka bir sekmeye aylar itibariyle toplam aldırabilir miyiz?Aylar itibariyle toplam aldırma
-
- Mesajlar: 3
- Kayıt: 02 Oca 2024, 16:42
- Lokasyon: Gaziantep
- Meslek: 3D Üretim Uzmanı
- Adınız: Osman
- Soyadınız: Kartal
Aylar itibariyle toplam aldırma
Bu liste girildikten sonra başka bir sekmeye aylar itibariyle toplam aldırabilir miyiz?
Bu mesaja eklenen dosyaları görüntülemek için gerekli izinlere sahip değilsiniz.
-
- Mesajlar: 16
- Kayıt: 11 Eki 2023, 13:56
- Meslek: Memur
- Adınız: Ahmet
- Soyadınız: KARIŞMA
Re: Aylar itibariyle toplam aldırma
Kod: Tümünü seç
Dim wsSource As Worksheet
Dim wsTarget As Worksheet
Dim lastRow As Long
Dim i As Long
Dim monthTotal As Double
Set wsSource = ThisWorkbook.Sheets("Sayfa1") ' Verilerimizin alınacağı sayfa adı
Set wsTarget = ThisWorkbook.Sheets("Sayfa2") ' Ay itibariyle toplam satışların aktarılması istenilen sayfa adı.
lastRow = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row
Dim salesByMonth As Object
Set salesByMonth = CreateObject("Scripting.Dictionary")
For i = 2 To lastRow
Dim saleDate As Date
saleDate = wsSource.Cells(i, "A").Value
Dim saleAmount As Double
saleAmount = wsSource.Cells(i, "D").Value
Dim saleMonth As String
saleMonth = Format(saleDate, "MMMM yyyy")
If Not salesByMonth.Exists(saleMonth) Then
salesByMonth(saleMonth) = saleAmount
Else
salesByMonth(saleMonth) = salesByMonth(saleMonth) + saleAmount
End If
Next i
Dim resultRow As Long
resultRow = 2
wsTarget.Cells(1, "A").Value = "Ay"
wsTarget.Cells(1, "B").Value = "Toplam Satış Tutarı"
For Each Key In salesByMonth
wsTarget.Cells(resultRow, "A").Value = Key
wsTarget.Cells(resultRow, "B").Value = salesByMonth(Key)
resultRow = resultRow + 1
Next Key