Shazam
06-13-2006, 06:41 AM
Hi everyone!
I'm trying to get this into a vba code but some reason I'm not doing it correctly.
Here is the formula it sum unique values.
=SUMPRODUCT(--(B3:B40<>""),--(MATCH(F3:F40&N3:N40,F3:F40&N3:N40,0)=ROW(INDEX(F3:F40,0,0))-ROW($A$3)+1),N3:N40)
I got this far but no luck. Any help?
Sub Sum()
Dim maxrow As Long, Db As String, frmla As String
maxrow = Range("N65536").End(xlUp).Row - 1
Db = Chr(34)
frmla = "=SUMPRODUCT(--(B3:B" & maxrow & "<>),--(MATCH(F3:F" & maxrow & "&N3:N" & maxrow & "" _
& ",F3:F" & maxrow & "&N3:N" & maxrow & ",0)=ROW(INDEX(F3:F" & maxrow & ",0))" _
& "-ROW(A3)+1),N3:N" & maxrow & ")"
Range("N" & maxrow + 1).Formula = frmla
End Sub
The debugger highlight this line and gives me a runtime error '1004'
Range("N" & maxrow + 1).Formula = frmla
I'm trying to get this into a vba code but some reason I'm not doing it correctly.
Here is the formula it sum unique values.
=SUMPRODUCT(--(B3:B40<>""),--(MATCH(F3:F40&N3:N40,F3:F40&N3:N40,0)=ROW(INDEX(F3:F40,0,0))-ROW($A$3)+1),N3:N40)
I got this far but no luck. Any help?
Sub Sum()
Dim maxrow As Long, Db As String, frmla As String
maxrow = Range("N65536").End(xlUp).Row - 1
Db = Chr(34)
frmla = "=SUMPRODUCT(--(B3:B" & maxrow & "<>),--(MATCH(F3:F" & maxrow & "&N3:N" & maxrow & "" _
& ",F3:F" & maxrow & "&N3:N" & maxrow & ",0)=ROW(INDEX(F3:F" & maxrow & ",0))" _
& "-ROW(A3)+1),N3:N" & maxrow & ")"
Range("N" & maxrow + 1).Formula = frmla
End Sub
The debugger highlight this line and gives me a runtime error '1004'
Range("N" & maxrow + 1).Formula = frmla