dependant summing

G

greg

Hello,
I would like to sum some numbers. But depending on 2 other column.
Say I have 3 named ranges.
the A column, B column and c column. = Range1, Range2, Range3

Range3 (column C) has numbers. Range 1, 2 are strings.

If I wanted to sum numbers in Range3 when Range1 = "ABC" and Range2 = "DEF"

do you use Sum (Range1="ABC....
Or do I need If statments?

thanks for any help
 
M

Mike

this is an array formula, so press Ctrl+Shift+Enter after pasting it into a
cell
=SUM((A1:A10="ABC")*(B1:B10="DEF")*C1:C10)
 
G

greg

thanks for the help.
If I wanted to move this to vba code. I would think something like this
would work.
However, I get an object does not support this method.

Any ideas on moving to VBA?


Sub test()

Dim x
x = Excel.WorksheetFunction.SumProduct(--(Excel.ActiveWorkbook("Range1") =
"ABC"), --(Excel.ActiveWorkbook("Range2") = "DEF"),
Excel.ActiveWorkbook("Range3"))

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top