Sumproduct using Variable range

Abgar

Active Member
Joined
Jun 20, 2009
Messages
255
Hi guys, I'm using the following SUMPRODUCT formula in a macro.
Code:
Range("X5").Formula = "=(SUMPRODUCT(--(Call_Type=""NA""),--(Number_Called<>""Retrieve Voicemail""),--(Number_Called<>""Div to Voicemail""),--([COLOR=Red]Number_Called<>Excluded[/COLOR]),--(Call_Charge>0),(Charged_Seconds))+SUMPRODUCT(--(Call_Type=""V2O""),(Charged_Seconds)))/60"
But the Red part errors the SUMPRODUCT.
If I change the Excluded range to state the individual cells in the Named Range, it works (As below)
Code:
Range("X5").Formula = "=(SUMPRODUCT(--(Call_Type=""NA""),--(Number_Called<>""Retrieve Voicemail""),--(Number_Called<>""Div to Voicemail""),--([COLOR=Red]Number_Called<>""13""),--(Number_Called<>""1223""),--(Number_Called<>123),--(Number_Called<>""123""),--(Number_Called<>1234),--(Number_Called<>""1234""),--(Number_Called<>""12455""),--(Number_Called<>12455[/COLOR]),--(Call_Charge>0),(Charged_Seconds))+SUMPRODUCT(--(Call_Type=""V2O""),(Charged_Seconds)))/60"
Is it possible to use a Named Range as a condition in a SUMPRODUCT formula?
If so, how would it look?
And is there a neater way to do this than what I'm using?

Thanks Guys :)
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Abgar

Active Member
Joined
Jun 20, 2009
Messages
255
Sorry, I should say BTW, that the reason i don't want to list ALL of the values for Range Name "Excluded", is because this range will be added to sporadically, and i don't want to have to re-do the whole SUMPRODUCT if i can help it.

Cheers again :)
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,201
Does the formula suceeed with the following bit?...

--ISNA(MATCH(Number_Called,Excluded,0))
 

Abgar

Active Member
Joined
Jun 20, 2009
Messages
255
Note To Self - Need to slow down and think.....

Sorry Aladin, no you're coding didn't work, it distorted all of the values. But that made me think, and re-checking, the "Excluded" Range hadn't been properly defined.

have redefined it now and a simple =SUMPRODUCT(Number_Called<>Excluded).........." works.

Thanks for your help anyway though :)
 

Abgar

Active Member
Joined
Jun 20, 2009
Messages
255
Ok, so I was wrong....

It looked right, but then did manual calculations to confirm the figures and i was out. By the exact amount of the Excluded items.

So i have then gone and tried Aladin's formula
Code:
(--(ISNA(MATCH(Number_Called,Excluded,0)))
And it works perfectly.

Thanks so much Aladin, now I've double checked and triple checked, and the figures are correct - using your code.

You legend - Thanks millions :)
 

Watch MrExcel Video

Forum statistics

Threads
1,122,223
Messages
5,594,908
Members
413,952
Latest member
JGer

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
Top