ich bekomme in der nachfolgenden Formel den Teil *** "=""BMW"" *** nicht über eine Variable zugewiesen.
Hier mein Code:
Sub SummenproduktFunktioniert()
Dim iCol%: iCol = 3
Dim iLz%: iLz = Cells(Cells.Rows.Count, 1).End(xlUp).Row
Dim mon%: mon = 2
With wsSP
.[F1] = Evaluate("SumProduct((SP!A1:A" & iLz & "=""BMW"")*(SP!B1:B6=" & mon & ")*(" _
& .Range(.Cells(1, iCol), .Cells(iLz, iCol)).Address & ")*(SP!D1:D6))")
End With
End Sub
Sub SummenproduktFunktioniertNicht()
Dim iCol%: iCol = 3
Dim iLz%: iLz = Cells(Cells.Rows.Count, 1).End(xlUp).Row
Dim mon%: mon = 2: Dim Typ$: Typ = "BMW"
With wsSP
.[F1] = Evaluate("SumProduct((SP!A1:A" & iLz & "="" & Typ & "")*(SP!B1:B6=" & mon & ")*(" _
_
& .Range(.Cells(1, iCol), .Cells(iLz, iCol)).Address & ")*(SP!D1:D6))")
End With
End Sub
Ich finde nicht den richtigen Weg die "" zu setzten...Hier auch als Datei:
https://www.herber.de/bbs/user/70751.xls
Gruß
Peter