Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am having trouble writing this into my VBA. I wrote this for 2007 however, I need it to work for 2003. Here is what I had for the 2007 version: c.Value = c & "-" & WorksheetFunction.CountIfs(Range("B2:B" & LastRow), c.Offset(0, -1), Range("A2:A" & LastRow), c.Offset(0, -2)) I need to use WorksheetFuction with VBA since the formula is going to use the current value of the cell. This line works great for 2007 as it is COUNTIFS. However, I need to turn this into 2003 and use SUMPRODUCT. I know the formula should work out to be =SUMPRODUCT(($A$2:$A$22=A5)*($B$2:$B$22=B5)) with the A22 and B22 being a variable cell based off my LastRow value. I thought this might work, but it does not: c.Value = c & "-" & WorksheetFunction.SumProduct((Range("B2:B" & LastRow) & "=" & c.Offset(0, -1)) & "*" & (Range("A2:A" & LastRow) & "=" & c.Offset(0, -2))) Any ideas? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sumproduct with Condition OR Sumproduct with ADDRESS function - HE | Excel Discussion (Misc queries) | |||
SUMPRODUCT | Excel Discussion (Misc queries) | |||
Sumproduct | Excel Worksheet Functions | |||
Conditional SUMPRODUCT or SUMPRODUCT with Filters | Excel Worksheet Functions | |||
sumproduct? sumif(sumproduct)? | Excel Worksheet Functions |