Topla.Çarpım VBA kodu

walabi

Altın Üye
Katılım
22 Eylül 2012
Mesajlar
964
Excel Vers. ve Dili
excel 2010

excel 2013
Altın Üyelik Bitiş Tarihi
06-08-2025
Merhaba,

Aşağıda topla.çarpım ile oluşturmaya çalıştığım kod var. Ancak hata veriyor. Hata sebebi nedir. Normal fonksiyonun işleyişine göre vba ya uyarlamaya çalıştım. Ancak olmadı.



Bu formülü

Kod:
=TOPLA.ÇARPIM(ESAYIYSA(KAÇINCI(REÇETE!$B$2:$B$9999;K2;0))*ESAYIYSA(KAÇINCI(REÇETE!$C$2:$C$9999;L2;0))*ESAYIYSA(KAÇINCI(REÇETE!$A$2:$A$9999;$G$2:$G$151;0))*(REÇETE!$D$2:$D$9999))
Bu VBA koduna uyarlamaya çalıştım

Kod:
For i = 2 To sonsat



    s2.Cells(i, "M") = WorksheetFunction.SumProduct( _
                        (WorksheetFunction.IsNumber(WorksheetFunction.Match(s3.Range("B2:B9999"), s2.Cells(i, "K"), 0))) * _
                        (WorksheetFunction.IsNumber(WorksheetFunction.Match(s3.Range("L2:L9999"), s2.Cells(i, "L"), 0))) * _
                        (WorksheetFunction.IsNumber(WorksheetFunction.Match(s3.Range("A2:A9999"), s2.Range("G2:G" & sonsat), 0))) * _
                        (s3.Range("D2:D9999")))


Next i
 
Katılım
11 Temmuz 2024
Mesajlar
247
Excel Vers. ve Dili
Excel 2021 Türkçe
Merhaba, şöyle dener misiniz;

Kod:
For i = 2 To sonsat
    s2.Cells(i, "M").Formula = "=TOPLA.ÇARPIM(ESAYIYSA(KAÇINCI(" & s3.Name & "!$B$2:$B$9999;" & s2.Cells(i, "K").Address(False, False) & ";0))*ESAYIYSA(KAÇINCI(" & s3.Name & "!$C$2:$C$9999;" & s2.Cells(i, "L").Address(False, False) & ";0))*ESAYIYSA(KAÇINCI(" & s3.Name & "!$A$2:$A$9999;$G$2:$G$" & sonsat & ";0))*(" & s3.Name & "!$D$2:$D$9999))"
Next i
Formulün işleyişine göre VBA kodu isterseniz eğer:

Kod:
Dim toplam As Double
Dim j As Long
Dim bulundu As Boolean

For i = 2 To sonsat
    toplam = 0
    For j = 2 To 9999
        If IsEmpty(s3.Cells(j, "A").Value) And IsEmpty(s3.Cells(j, "B").Value) Then Exit For
        
        If s3.Cells(j, "B").Value = s2.Cells(i, "K").Value And _
           s3.Cells(j, "C").Value = s2.Cells(i, "L").Value Then
            bulundu = False
            For k = 2 To sonsat
                If s3.Cells(j, "A").Value = s2.Cells(k, "G").Value Then
                    bulundu = True
                    Exit For
                End If
            Next k
            If bulundu Then
                toplam = toplam + s3.Cells(j, "D").Value
            End If
        End If
    Next j
    s2.Cells(i, "M").Value = toplam
Next i
 

walabi

Altın Üye
Katılım
22 Eylül 2012
Mesajlar
964
Excel Vers. ve Dili
excel 2010

excel 2013
Altın Üyelik Bitiş Tarihi
06-08-2025
Merhaba, şöyle dener misiniz;

Kod:
For i = 2 To sonsat
    s2.Cells(i, "M").Formula = "=TOPLA.ÇARPIM(ESAYIYSA(KAÇINCI(" & s3.Name & "!$B$2:$B$9999;" & s2.Cells(i, "K").Address(False, False) & ";0))*ESAYIYSA(KAÇINCI(" & s3.Name & "!$C$2:$C$9999;" & s2.Cells(i, "L").Address(False, False) & ";0))*ESAYIYSA(KAÇINCI(" & s3.Name & "!$A$2:$A$9999;$G$2:$G$" & sonsat & ";0))*(" & s3.Name & "!$D$2:$D$9999))"
Next i
Formulün işleyişine göre VBA kodu isterseniz eğer:

Kod:
Dim toplam As Double
Dim j As Long
Dim bulundu As Boolean

For i = 2 To sonsat
    toplam = 0
    For j = 2 To 9999
        If IsEmpty(s3.Cells(j, "A").Value) And IsEmpty(s3.Cells(j, "B").Value) Then Exit For
       
        If s3.Cells(j, "B").Value = s2.Cells(i, "K").Value And _
           s3.Cells(j, "C").Value = s2.Cells(i, "L").Value Then
            bulundu = False
            For k = 2 To sonsat
                If s3.Cells(j, "A").Value = s2.Cells(k, "G").Value Then
                    bulundu = True
                    Exit For
                End If
            Next k
            If bulundu Then
                toplam = toplam + s3.Cells(j, "D").Value
            End If
        End If
    Next j
    s2.Cells(i, "M").Value = toplam
Next i

Formül olanı çalıştıramadım, benden kaynaklanıyor olabilir. Ancak kod çalışıyor. Teşekkürler.
 
Üst