Endless033
Altın Üye
- Katılım
- 25 Haziran 2013
- Mesajlar
- 140
- Excel Vers. ve Dili
- türkçe
- Altın Üyelik Bitiş Tarihi
- 07-09-2025
Option Explicit
Sub tarihRaporla()
Dim a() As Variant, boy1 As Long
Dim veri As Worksheet, defter As Worksheet
Dim vsay As Long, dsay As Long, dd1 As Long
Dim tare1 As Double, tare2 As Double, tary1 As Double, tary2 As Double
Dim g9a As Double, g9b As Double, g10 As Double, g11 As Double, g12 As Double
Dim g16a As Double, g16b As Double, g17 As Double, g18 As Double
Set veri = Worksheets("VERİ"): Set defter = Worksheets("İŞLETME DEFTERİ")
tary1 = CDbl(defter.Range("B6")): tary2 = CDbl(defter.Range("D6"))
tare1 = DateSerial(Year(tary1), Month(tary1) - 1, 1): tare2 = DateSerial(Year(tare1), Month(tare1) + 1, 0)
dsay = defter.Range("A" & Rows.Count).End(xlUp).Row
If dsay < 9 Then dsay = 9
defter.Range("A9" & dsay).ClearContents
defter.Range("G9:G12").ClearContents: defter.Range("G16:G18").ClearContents
vsay = veri.Range("A" & Rows.Count).End(xlUp).Row
boy1 = WorksheetFunction.CountIfs(veri.Range("A4:A" & vsay), ">=" & tary1, _
veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("P4" & vsay), ">0")
ReDim Preserve a(1 To boy1, 1 To 4): boy1 = 0
For dd1 = 4 To vsay
If veri.Range("A" & dd1) >= tary1 And veri.Range("A" & dd1) <= tary2 And veri.Range("P" & dd1) > 0 Then
boy1 = boy1 + 1
a(boy1, 1) = veri.Range("A" & dd1) 'Tarih
a(boy1, 2) = veri.Range("F" & dd1) 'Belge No
a(boy1, 3) = veri.Range("G" & dd1) 'Açıklama
a(boy1, 4) = veri.Range("P" & dd1) 'Tutar
End If
Next dd1
defter.Range("A9").Resize(UBound(a, 1), UBound(a, 2)) = a: Erase a()
g9a = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), ">=" & tare1, _
veri.Range("A4:A" & vsay), "<=" & tare2)
g9b = WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("A4:A" & vsay), ">=" & tare1, _
veri.Range("A4:A" & vsay), "<=" & tare2)
g9a = g9a - g9b
g10 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), _
">=" & tary1, veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("N4:N" & vsay), "ŞEKERBANK")
g11 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), _
">=" & tary1, veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("N4:N" & vsay), "HALKBANK")
g12 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), ">=" & tary1, _
veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("E4:E" & vsay), "KASA", veri.Range("J4:J" & vsay), "AİDAT ÜCRET GELİRLERİ")
g12 = g12 + WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), ">=" & tary1, _
veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("E4:E" & vsay), "KASA", veri.Range("J4:J" & vsay), "DİĞER GELİRLER")
g16a = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("E4:E" & vsay), "KASA")
g16b = WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("E4:E" & vsay), "KASA")
g16a = g16a - g16b
g17 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("N4:N" & vsay), "ŞEKERBANK")
g17 = g17 - WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("N4:N" & vsay), "ŞEKERBANK")
g18 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("N4:N" & vsay), "HALKBANK")
g18 = g18 - WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("N4:N" & vsay), "HALKBANK")
defter.Range("G9") = g9a: defter.Range("G10") = g10
defter.Range("G11") = g11: defter.Range("G12") = g12
defter.Range("G16") = g16a: defter.Range("G17") = g17
defter.Range("G18") = g18
MsgBox "İşlem başarı ile tamamlandı.", vbInformation, "İŞLEM TAMAM"
End Sub
arkadaşlar dosyamda işletme defterinde g9 sutunu bir önceki ayın son bakiyesini getiyor benim yapmak istediğim örnek veriyorum 12 ayı raporla dediğimde 1 aydan 11 ayın sonuna kadar son bakiyesini yazması 3 ayı raporla dediğimde 1 kapsayacak çekilde 2 ayın sonundaki bakiyeyi getirmesi
Sub tarihRaporla()
Dim a() As Variant, boy1 As Long
Dim veri As Worksheet, defter As Worksheet
Dim vsay As Long, dsay As Long, dd1 As Long
Dim tare1 As Double, tare2 As Double, tary1 As Double, tary2 As Double
Dim g9a As Double, g9b As Double, g10 As Double, g11 As Double, g12 As Double
Dim g16a As Double, g16b As Double, g17 As Double, g18 As Double
Set veri = Worksheets("VERİ"): Set defter = Worksheets("İŞLETME DEFTERİ")
tary1 = CDbl(defter.Range("B6")): tary2 = CDbl(defter.Range("D6"))
tare1 = DateSerial(Year(tary1), Month(tary1) - 1, 1): tare2 = DateSerial(Year(tare1), Month(tare1) + 1, 0)
dsay = defter.Range("A" & Rows.Count).End(xlUp).Row
If dsay < 9 Then dsay = 9
defter.Range("A9" & dsay).ClearContents
defter.Range("G9:G12").ClearContents: defter.Range("G16:G18").ClearContents
vsay = veri.Range("A" & Rows.Count).End(xlUp).Row
boy1 = WorksheetFunction.CountIfs(veri.Range("A4:A" & vsay), ">=" & tary1, _
veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("P4" & vsay), ">0")
ReDim Preserve a(1 To boy1, 1 To 4): boy1 = 0
For dd1 = 4 To vsay
If veri.Range("A" & dd1) >= tary1 And veri.Range("A" & dd1) <= tary2 And veri.Range("P" & dd1) > 0 Then
boy1 = boy1 + 1
a(boy1, 1) = veri.Range("A" & dd1) 'Tarih
a(boy1, 2) = veri.Range("F" & dd1) 'Belge No
a(boy1, 3) = veri.Range("G" & dd1) 'Açıklama
a(boy1, 4) = veri.Range("P" & dd1) 'Tutar
End If
Next dd1
defter.Range("A9").Resize(UBound(a, 1), UBound(a, 2)) = a: Erase a()
g9a = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), ">=" & tare1, _
veri.Range("A4:A" & vsay), "<=" & tare2)
g9b = WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("A4:A" & vsay), ">=" & tare1, _
veri.Range("A4:A" & vsay), "<=" & tare2)
g9a = g9a - g9b
g10 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), _
">=" & tary1, veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("N4:N" & vsay), "ŞEKERBANK")
g11 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), _
">=" & tary1, veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("N4:N" & vsay), "HALKBANK")
g12 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), ">=" & tary1, _
veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("E4:E" & vsay), "KASA", veri.Range("J4:J" & vsay), "AİDAT ÜCRET GELİRLERİ")
g12 = g12 + WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("A4:A" & vsay), ">=" & tary1, _
veri.Range("A4:A" & vsay), "<=" & tary2, veri.Range("E4:E" & vsay), "KASA", veri.Range("J4:J" & vsay), "DİĞER GELİRLER")
g16a = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("E4:E" & vsay), "KASA")
g16b = WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("E4:E" & vsay), "KASA")
g16a = g16a - g16b
g17 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("N4:N" & vsay), "ŞEKERBANK")
g17 = g17 - WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("N4:N" & vsay), "ŞEKERBANK")
g18 = WorksheetFunction.SumIfs(veri.Range("O4:O" & vsay), veri.Range("N4:N" & vsay), "HALKBANK")
g18 = g18 - WorksheetFunction.SumIfs(veri.Range("P4" & vsay), veri.Range("N4:N" & vsay), "HALKBANK")
defter.Range("G9") = g9a: defter.Range("G10") = g10
defter.Range("G11") = g11: defter.Range("G12") = g12
defter.Range("G16") = g16a: defter.Range("G17") = g17
defter.Range("G18") = g18
MsgBox "İşlem başarı ile tamamlandı.", vbInformation, "İŞLEM TAMAM"
End Sub
arkadaşlar dosyamda işletme defterinde g9 sutunu bir önceki ayın son bakiyesini getiyor benim yapmak istediğim örnek veriyorum 12 ayı raporla dediğimde 1 aydan 11 ayın sonuna kadar son bakiyesini yazması 3 ayı raporla dediğimde 1 kapsayacak çekilde 2 ayın sonundaki bakiyeyi getirmesi
Ekli dosyalar
-
191.6 KB Görüntüleme: 5