Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default SumProduct - Why won't it work?

Hi,

I'm trying to use SumProduct in conjuction with some variables, and I can't
get the syntax correct. I've copied a few examples from the discussion
group but the result is always 0 (where x = 1, the SumProduct result should
be 200). There's a basic example below.

Company Order Description Price

2 4450 Apple £100.00
4 88 Banana £25.00
2 4451 Banana £25.00
2 4450 Apple £100.00
2 4552 Cherry £30.00

I want to find out the total for a particular order.

myRowsO = Sheets("Orders").Range("A6").CurrentRegion.Rows.Co unt (ok)

For x = 1 To myRowsO + 5 (ok)

OrderO = Sheets("Orders").Range("B" & x + 5) (ok)

TotalO = ActiveSheet.Evaluate("SUMPRODUCT((B6:B" & myRowsO + 5 & "=""" &
OrderO & """)*(D6:D" & myRowsO + 5 & "))") (not ok)



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default SumProduct - Why won't it work?

Helen,

You are putting a number into quotes, which converts it to a string. Try

TotalO = ActiveSheet.Evaluate("SUMPRODUCT((B6:B" & myRowsO + 5 & "=" &
OrderO & ")*(D6:D" & myRowsO + 5 & "))")

Also, you are adding 5 one more time than you need:

For x = 1 To myRowsO + 5

should be

For x = 1 To myRowsO

or even

For x = 1 To myRowsO - 1


HTH,
Bernie
MS Excel MVP


"Helen" wrote in message
...
Hi,

I'm trying to use SumProduct in conjuction with some variables, and I can't
get the syntax correct. I've copied a few examples from the discussion
group but the result is always 0 (where x = 1, the SumProduct result should
be 200). There's a basic example below.

Company Order Description Price

2 4450 Apple £100.00
4 88 Banana £25.00
2 4451 Banana £25.00
2 4450 Apple £100.00
2 4552 Cherry £30.00

I want to find out the total for a particular order.

myRowsO = Sheets("Orders").Range("A6").CurrentRegion.Rows.Co unt (ok)

For x = 1 To myRowsO + 5 (ok)

OrderO = Sheets("Orders").Range("B" & x + 5) (ok)

TotalO = ActiveSheet.Evaluate("SUMPRODUCT((B6:B" & myRowsO + 5 & "=""" &
OrderO & """)*(D6:D" & myRowsO + 5 & "))") (not ok)





Reply
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
Will sumproduct work? Risky Dave Excel Worksheet Functions 1 February 4th 09 12:00 PM
SUMPRODUCT won't work on a row PFB Excel Worksheet Functions 5 November 13th 08 08:42 AM
sumproduct doesn't work Bonkers Excel Worksheet Functions 9 April 22nd 06 05:28 PM
Will SUMPRODUCT work for this? Aaron Saulisberry Excel Discussion (Misc queries) 4 January 25th 06 01:05 PM
Sumproduct wont work Mycotopian[_3_] Excel Programming 2 August 5th 04 08:06 PM


All times are GMT +1. The time now is 07:21 AM.

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

About Us

"It's about Microsoft Excel"