Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

Hi all,

I have a problem in VBA using application.sumproduct.
The following code does not work:

Application.SumProduct((Application.Index(holdings .Range("holdings"),
0, 1) = "ff") * (Application.Index(holdings.Range("holdings"), 0, 5) =
"gg") * Application.Index(holdings.Range("holdings"), 0, 3))

Can anyone help me? Thanks heaps!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

Try application.WorksheetFunction.SumProduct

On Dec 30, 12:08*pm, Majken Bilslev-Jensen
wrote:
Hi all,

I have a problem in VBA using application.sumproduct.
The following code does not work:

Application.SumProduct((Application.Index(holdings .Range("holdings"),
0, 1) = "ff") * (Application.Index(holdings.Range("holdings"), 0, 5) =
"gg") * Application.Index(holdings.Range("holdings"), 0, 3))

Can anyone help me? Thanks heaps!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

Makes no difference....
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

That applies to all the functions you use - also the .index
Did you make that change too?
As far as I know the only way to reference/use genuine Excel Worksheet
functions is via the:
application.worksheetfunction.
construct.
So, did you make that other change too?


On Dec 30, 12:48*pm, Majken Bilslev-Jensen
wrote:
Makes no difference....


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

I don't think VBA can evaluate this "formula" like Excel itself can. It
breaks down pretty early in the process.

While it can do this:

Dim Arr As Variant
Arr = Application.Index(Range("Holdings"), 0, 1)

returning an array of the values in column 1 of Holdings, you would hope
that this:

Dim Arr As Variant
Arr = (Application.Index(Range("Holdings"), 0, 1) = "ff")

would return an array of True and False. But it errors. I think in VBA you
just have to address each element of the array individually.


"Majken Bilslev-Jensen" wrote in message
...
Hi all,

I have a problem in VBA using application.sumproduct.
The following code does not work:

Application.SumProduct((Application.Index(holdings .Range("holdings"),
0, 1) = "ff") * (Application.Index(holdings.Range("holdings"), 0, 5) =
"gg") * Application.Index(holdings.Range("holdings"), 0, 3))

Can anyone help me? Thanks heaps!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

It appears that Jim is right - I'm also getting the type-mismatch
error.
Perhaps you can work around this by using some tempcell - put the
formula into a cell, get Excel to evalueate it, read the cells value
and then remove the formula from the cel...
Not an elegant solution but...


On Dec 30, 12:58*pm, "Jim Rech" wrote:
I don't think VBA can evaluate this "formula" like Excel itself can. It
breaks down pretty early in the process.

While it can do this:

*Dim Arr As Variant
*Arr = Application.Index(Range("Holdings"), 0, 1)

returning an array of the values in column 1 of Holdings, you would hope
that this:

*Dim Arr As Variant
*Arr = (Application.Index(Range("Holdings"), 0, 1) = "ff")

would return an array of True and False. But it errors. *I think in VBA you
just have to address each element of the array individually.

"Majken Bilslev-Jensen" wrote in message

...



Hi all,


I have a problem in VBA using application.sumproduct.
The following code does not work:


Application.SumProduct((Application.Index(holdings .Range("holdings"),
0, 1) = "ff") * (Application.Index(holdings.Range("holdings"), 0, 5) =
"gg") * Application.Index(holdings.Range("holdings"), 0, 3))


Can anyone help me? Thanks heaps!- Hide quoted text -


- Show quoted text -


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

On Dec 30, 7:12*am, AB wrote:
It appears that Jim is right - I'm also getting the type-mismatch
error.
Perhaps you can work around this by using some tempcell - put the
formula into a cell, get Excel to evalueate it, read the cells value
and then remove the formula from the cel...
Not an elegant solution but...

On Dec 30, 12:58*pm, "Jim Rech" wrote:



I don't think VBA can evaluate this "formula" like Excel itself can. It
breaks down pretty early in the process.


While it can do this:


*Dim Arr As Variant
*Arr = Application.Index(Range("Holdings"), 0, 1)


returning an array of the values in column 1 of Holdings, you would hope
that this:


*Dim Arr As Variant
*Arr = (Application.Index(Range("Holdings"), 0, 1) = "ff")


would return an array of True and False. But it errors. *I think in VBA you
just have to address each element of the array individually.


"Majken Bilslev-Jensen" wrote in message


....


Hi all,


I have a problem in VBA using application.sumproduct.
The following code does not work:


Application.SumProduct((Application.Index(holdings .Range("holdings"),
0, 1) = "ff") * (Application.Index(holdings.Range("holdings"), 0, 5) =
"gg") * Application.Index(holdings.Range("holdings"), 0, 3))


Can anyone help me? Thanks heaps!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


With sumproduct you must use application.EVALUATE("your formula")
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default Sumproduct instead of SumifS in VBA (application.sumproduct)

On Dec 30, 4:08*am, Majken Bilslev-Jensen
wrote:
The following code does not work:

Application.SumProduct((Application.Index(holdings .Range("holdings"),
0, 1) = "ff") * (Application.Index(holdings.Range("holdings"), 0, 5) =
"gg") * Application.Index(holdings.Range("holdings"), 0, 3))


Try this:

Evaluate("SUMPRODUCT((INDEX(Holdings,0,1)="ff")*(I NDEX(Holdings,
0,5)="gg"),
INDEX(Holdings,0,3)")

Note: Enter the entire formula on __one__ VBA line or use apply VBA
line continuation syntax appropriately.
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
Excel 2007 -- SUMIFS v SUMPRODUCT MurrayBarn Excel Worksheet Functions 4 June 12th 09 02:53 PM
Are SUMIFS and SUMPRODUCT the same? wx4usa Excel Discussion (Misc queries) 3 December 8th 08 10:22 AM
Application.Worksheetfunction.Sumproduct Tetsuya Oguma Excel Programming 4 July 16th 08 01:43 PM
application.sumproduct help please Gareth[_3_] Excel Programming 6 August 22nd 05 12:30 AM
application.sumproduct help please Gareth[_3_] Excel Programming 0 August 21st 05 01:50 PM


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