Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default mixing of vba and sumproduct

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("OrderMonthNam e") =
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default mixing of vba and sumproduct


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)] )

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default mixing of vba and sumproduct

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.... =(


"abcd" wrote:


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)] )


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default mixing of vba and sumproduct

J,

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


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

HTH,
Bernie
MS Excel MVP


"Gixxer_J_97" wrote in message
...
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("OrderMonthNam e") =
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default mixing of vba and sumproduct

You rock!

thanks!

J

"Bernie Deitrick" wrote:

J,

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


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

HTH,
Bernie
MS Excel MVP


"Gixxer_J_97" wrote in message
...
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("OrderMonthNam e") =
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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default mixing of vba and sumproduct

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...
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
mixing zip with zip+4 and then sorting JWCrosby Excel Discussion (Misc queries) 2 September 25th 08 08:48 PM
Mixing text and alpha in sumproduct arrays expect_ed Excel Worksheet Functions 5 August 7th 08 10:39 PM
mixing up a list dkb43 Excel Discussion (Misc queries) 1 August 6th 08 08:20 PM
Mixing up the arguments michaelr586 Excel Worksheet Functions 2 September 24th 05 09:54 AM
Newbie at mixing ADO and Excel Bryan Dickerson Excel Programming 15 January 7th 05 10:19 PM


All times are GMT +1. The time now is 01:55 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"