Sumproduct using Variable range

Abgar

Active Member
Joined
Jun 20, 2009
Messages
265
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 :)
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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 :)
 
Upvote 0
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 :)
 
Upvote 0
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 :)
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,142
Members
448,551
Latest member
Sienna de Souza

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