Hi All,
I am going to use sumproduct function from VBA. My problem is that the first msgbox is simple doesn't work. (I attached a small xl file with the VBA code)
Maybe somebody has an idea to correct this code.
Thx and rgds,
Janos
-----------------------
[VBA]
Sub Test2sumproduct()
Dim r1 As Range
Dim x As Variant
Dim i As Integer
Dim StartDate As Date
Dim Cat As Range
Dim tCatName() As String
Dim iCatNumber As Integer
Sheets("sheet1").Select
Range("L2").Select
Range(Selection, Selection.End(xlDown)).Select
Set r1 = Selection
x = r1.Value
ReDim tCatName(UBound(x, 1))
iCatNumber = UBound(x, 1)
For i = 1 To iCatNumber
tCatName(i) = Cells(i + 1, 12)
Next i
StartDate = Cells(1, 10) - 1
MsgBox ActiveSheet.Evaluate("SUMPRODUCT(--(A3:A300>=""& StartDate & "")*--(B3:B300=""& tCatName & "")*--(C3:C300))")
MsgBox ActiveSheet.Evaluate("SUMPRODUCT(--(A3:A300>=J1)*--(B3:B300=""a"")*--(C3:C300))")
MsgBox ActiveSheet.Evaluate("SUMPRODUCT(--(A3:A300>=J1)*--(B3:B300=""a"")*--(d3:d300)*--(E3:E300=""X""))")
End Sub
[/VBA]