Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default SUMPRODUCT IN VBA

hello,
Using the search, I have tried to find a way to program SUMPRODUCT in VBA,
but I am not sure I am using it properly.
Can you check what I am doing wrong.
I do not want to copy the formula in Excel, i am after the final value.
Thanks
Caroline

For i = 1 To 200

Dim EvalRange As Range
Set EvalRange = Range(Cell1.Offset((i - 1) * 23, 2),
Cell1.Offset(i * 23 - 1, 2))
Dim sumrange As Range
Set sumrange = Range(Cell1.Offset((i - 1) * 23, X),
Cell1.Offset(i * 23 - 1, X))

For j = 1 To 3
minAge = Range("Ageband")(j, 0).Value
maxAge = Range("Ageband")(j, 1).Value

Cell2.Offset((i - 1) * j, 3).Value =
Evaluate("SUMPRODUCT((EvalRange=minAge),(EvalRang e<MaxAge),(sumrange))")

Next

Next

PS; cell1 and cell2 are defined as range etc

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default SUMPRODUCT IN VBA

You cannot use the variables within the string being evaluated, you have to
use their values

Evaluate("SUMPRODUCT((" & EvalRange.Address & "=" & minAge & "),(" &
EvalRange.Address & "<" & MaxAge & ")," & sumrange.Address & ")")


--
__________________________________
HTH

Bob

"caroline" wrote in message
...
hello,
Using the search, I have tried to find a way to program SUMPRODUCT in VBA,
but I am not sure I am using it properly.
Can you check what I am doing wrong.
I do not want to copy the formula in Excel, i am after the final value.
Thanks
Caroline

For i = 1 To 200

Dim EvalRange As Range
Set EvalRange = Range(Cell1.Offset((i - 1) * 23, 2),
Cell1.Offset(i * 23 - 1, 2))
Dim sumrange As Range
Set sumrange = Range(Cell1.Offset((i - 1) * 23, X),
Cell1.Offset(i * 23 - 1, X))

For j = 1 To 3
minAge = Range("Ageband")(j, 0).Value
maxAge = Range("Ageband")(j, 1).Value

Cell2.Offset((i - 1) * j, 3).Value =
Evaluate("SUMPRODUCT((EvalRange=minAge),(EvalRang e<MaxAge),(sumrange))")

Next

Next

PS; cell1 and cell2 are defined as range etc



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
Sumproduct with Condition OR Sumproduct with ADDRESS function - HE gholly Excel Discussion (Misc queries) 2 September 28th 09 05:07 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
Sumproduct Mike Excel Worksheet Functions 1 February 21st 07 02:39 PM
sumproduct Jerry Kinder New Users to Excel 7 March 9th 06 07:36 PM


All times are GMT +1. The time now is 12:29 PM.

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"