mixing of vba and sumproduct

G

Guest

hi all,

i would like to use vba and the sumproduct function

the excel formula version would be something like

=SumProduct((OrderMonthName=B1)*1)

i am trying
with sheets("Sheet1")
tot = tot + cdbl(Application.SumProduct((.Range("OrderMonthName") =
monthName(m))*1))
end with

but i am getting a type mismatch - i have a feeling i am using this
incorrectly.

any help?

tia!

J
 
A

abcd

1st , try:
Application.Worksheetfunctions.SumProduct

the:
try to remember under VBA, there is no matricial formula, so you can
not hope [ .Range("OrderMonthName") = monthName(m) ] to be a vector
(because there's no vector in VBA)

BUT you may try

tot = tot + cdbl( [SumProduct((OrderMonthName=B1)*1)] )
 
G

Guest

Hi - i did try that, and i'm getting a value of 2029 each time it loops -
which i'm pretty sure is the error code. so no luck yet.... =(
 
B

Bernie Deitrick

J,

For your example:
Application.Evaluate("SumProduct((OrderMonthName=B1)*1)")


For your code:
tot = tot + Application.Evaluate("SumProduct((OrderMonthName= """ _
& MonthName(m) & """)*1)")

HTH,
Bernie
MS Excel MVP
 
G

Guest

You rock!

thanks!

J

Bernie Deitrick said:
J,

For your example:
Application.Evaluate("SumProduct((OrderMonthName=B1)*1)")


For your code:
tot = tot + Application.Evaluate("SumProduct((OrderMonthName= """ _
& MonthName(m) & """)*1)")

HTH,
Bernie
MS Excel MVP
 
A

abcd

I'm surprise because i thought the evaluate function was (quite) the
same (in this case) than the [...] notation.

But, since it works now for you...
 

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

Similar Threads

SUMPRODUCT IN VBA 1
sumproduct in vba 3
VBA Sumproduct Help 6
Coding a SumProduct formula 2
VBA formula too long? 2
SumProduct in VBA 3
Sumproduct error 2
Using a UDF within SUMPRODUCT 10

Top