• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Ay Yıl

Katılım
26 Aralık 2008
Mesajlar
1,145
Excel Vers. ve Dili
EXCEL 2016 TÜRKÇE
Merhaba Arkadaşlar ay yıl seçimi yaptığımda o aya ayıt günlerin verilerini toplamak
 
Sayfa2 nin kod bölümüne ;
Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$B$2" Then Exit Sub
    
    Dim ws1 As Worksheet
    Dim ayTarihi As Date
    Dim sonSatir As Long, i As Long
    Dim toplam As Double
    Dim yil As Integer, ay As Integer

    Set ws1 = ThisWorkbook.Sheets("Sayfa1")
    
    ayTarihi = Me.Range("B2").Value
    yil = Year(ayTarihi)
    ay = Month(ayTarihi)
    
    sonSatir = ws1.Cells(ws1.Rows.Count, 1).End(xlUp).Row
    
    toplam = 0
    
    For i = 1 To sonSatir
        If Year(ws1.Cells(i, 1).Value) = yil And Month(ws1.Cells(i, 1).Value) = ay Then
            toplam = toplam + ws1.Cells(i, 2).Value
        End If
    Next i
    
    Me.Range("B3").Value = toplam
End Sub
 
Sayfa2 nin kod bölümüne ;
Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$B$2" Then Exit Sub
   
    Dim ws1 As Worksheet
    Dim ayTarihi As Date
    Dim sonSatir As Long, i As Long
    Dim toplam As Double
    Dim yil As Integer, ay As Integer

    Set ws1 = ThisWorkbook.Sheets("Sayfa1")
   
    ayTarihi = Me.Range("B2").Value
    yil = Year(ayTarihi)
    ay = Month(ayTarihi)
   
    sonSatir = ws1.Cells(ws1.Rows.Count, 1).End(xlUp).Row
   
    toplam = 0
   
    For i = 1 To sonSatir
        If Year(ws1.Cells(i, 1).Value) = yil And Month(ws1.Cells(i, 1).Value) = ay Then
            toplam = toplam + ws1.Cells(i, 2).Value
        End If
    Next i
   
    Me.Range("B3").Value = toplam
End Sub
makro değilde formülü yokmu
 
Deneyin
Kod:
=ÇOKETOPLA(Sayfa1!B:B; Sayfa1!A:A; ">="&TARİH(YIL(B2); AY(B2); 1); Sayfa1!A:A; "<="&SERİAY(B2; 0))
 
Geri
Üst