Sumproduct Syntax

johnnyb5

Board Regular
Joined
Dec 23, 2014
Messages
89
I researched past threads and found a sumproduct formula that I'm trying to adapt to my macro but I'm having terrible syntax issues. I need the sumproduct to meet five criteria then sum the remaining quantities in column M. My data is from columns A through X and about 600 rows but that does vary with each days download. I'm placing the formula in my summary table beginning in cell AA2 with the intent to drag down after I can get the syntax corrected. Any and all assistance is appreciated.

Range("AA2").Select
Activecell.Formula = "=SUMPRODUCT(--($A$1:$A & LstRw="=cells(0,-1) & "*"),--($C$1:$C & LstRw=xlFilterAutomaticFontColor),--($S$2:$S & LstRw="<>4EA and <>4EL"),--($T$2:$T & LstRw="E*"),--($W$2:$W & LstRw>"0"),$M$2:$M & LstRw)"

The first filter in column A references the ID code which is a 6 digit code in A and I'm identifying a four digit code in column Z "cells(0,-1)" with a wild card * character to select all of the six digit IDs in A that match the first 4 characters in column Z.
The second filter in column C is identifying black font (automatic font color) as unwanted products were previously identified by changing their font to red.
The third filter in column S is eliminating the product codes with 4EA and 4EL.
The forth filter in column T is identifying all product codes that start with E and includes the wild card *.
The fifth filter in column W is selecting all values greater in price than 0.
And finally in column M I'm trying to sum the remaining product quantities.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You're not expecting that those asterisks will behave as wildcards, are you?
 
Upvote 0
Perhaps the first filter should be re-written as:
Range("AA2").Select
Activecell.Formula = "=SUMPRODUCT(--(left($A$2:$A & LstRw, 4)="cells(0,-1)"),--
Would that work to match the first 4 characters in column A with the 4 digit ID code in Column Z (Formula is in column AA)?
 
Upvote 0
There are functions that accept wildcards, (AVERAGEIF(S), COUNTIF(S), SUMIF(S), HLOOKUP, VLOOKUP, MATCH, SEARCH), but not SUMPRODUCT.

I can't tell from your example what is supposed to be a VBA variable versus a named formula.
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,015
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top