LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default SumProduct in VBA

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sumproduct with Condition OR Sumproduct with ADDRESS function - HE gholly Excel Discussion (Misc queries) 2 September 28th 09 05:07 PM
SUMPRODUCT George Excel Discussion (Misc queries) 1 April 6th 09 07:28 PM
Sumproduct lisay Excel Worksheet Functions 1 March 31st 09 04:49 PM
Conditional SUMPRODUCT or SUMPRODUCT with Filters Ted M H Excel Worksheet Functions 4 August 14th 08 07:50 PM
sumproduct? sumif(sumproduct)? David Excel Worksheet Functions 3 July 13th 07 07:06 PM


All times are GMT +1. The time now is 03:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"