I wanna calculate the sum of a column using the sumproduct command

=SUMPRODUCT(((A2:A7)=E2)*((B2:B7)=F2)*(C2:C7))

Calculates the Sum of values in C whenever A has E2 and B has F2

Now, how do I modify it to A2:Ax , etc. where the value of x is stored somewhere in the file, say at D1

Somebody mentioned using "A2:A" & x but I am getting an error if i use it

Maybe some syntactic error. For instance Sum("A2:A" & D1) gives an error.

Thanks