PDA

View Full Version : Solved: insert Sumproduct at the bottom of the data



Shazam
09-15-2006, 09:53 AM
Hi everyone,



I would like to input this formula at the bottom of the data in column Y

=SUMPRODUCT(--(B2:B74=1),--(Y3:Y75>0),Y3:Y75)


I wrote this code but It does not work. I must be missing like a quote or something.

FinalRow = Range("A65536").End(xlUp).Row + 1
Range("Y" & FinalRow + 1).Formula = "=SUMPRODUCT(--(B2:B" & FinalRow & "=1"""") " _
& ",--(Y3:Y" & FinalRow + 1 & ">0""""),Y3:Y" & FinalRow + 1 & ")"

Any Help.

Bob Phillips
09-15-2006, 10:00 AM
Shaz,

You were getting mixed up with your FinalRow, and +1, so I changed that.

You also introduced some spurious quotes in the conditions, I removed those.



Sub Shazam()
Dim FinalRow As Long

FinalRow = Cells(Rows.Count, "Y").End(xlUp).Row
Range("Y" & FinalRow + 1).Formula = "=SUMPRODUCT(--(B2:B" & FinalRow - 1 & "=1)" _
& ",--(Y3:Y" & FinalRow & ">0),Y3:Y" & FinalRow & ")"
End Sub

Shazam
09-15-2006, 10:23 AM
Thank so much xld!:hi: