Sum with multiple column lookup from multiple sheets with multiple criteria

DickieD

New Member
Joined
Jan 17, 2012
Messages
39
Hi All -- Been a whiiiiiile!

Think my brain is just fried or something; but I can't get this and rather than continue to wrack my brain figured I should just pose the question here.

I need to get a sum based on all column values of one sheet (call it "VALUESHEET") that are either NOT found in another column on another sheet (call it "CONTROLSHEET") or if they are found in that column, the value in another column on that second sheet is not a wildcard-driven constant.

Makes perfect sense right??

Said a different way: I want to "Sum" the values in Column D of my VALUESHEET if the values in the corresponding row of Column C on the VALUESHEET do not appear in Column A of my CONTROLSHEET *ONLY IF* if the value of any match in Column B of the control sheet is a specific wildcard-enabled constant (or a "Left"-first letter function can work if needed). And yes: the two sheets will always have a differing number of rows

Here's an example of what I have right now to get me up to the "*ONLY IF*" part:

Code:
=SUMPRODUCT(--(VALUESHEET!$A$2:$A$1000={A Constant}),--(VALUESHEET!$B$2:$B$1000={A Constant}),--(ISERROR(MATCH(VALUESHEET!$C$2:$C$1000*1,CONTROLSHEET!$A$2:$A$500,0))),VALUESHEET!$D$2:$D$1000)

But I need to somehow get a CONTROLSHEET!$B$2:$B$500<>"{CONSTANT}*" in there

I'm figuring there's got to be some simple way without having to use some type of additional matrix argument in the formula or something... but I just can't figure it out!

Let me know if I need to sample it out if my explanation doesn't do the trick. Thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Quick Bump guys

Just to add, I did figure out a loooooooong-way-around formula that kinda backs into the number.... but for 20000 rows it takes a good 100+ seconds to run (on a Quad-core) -- and I just KNOOOOOOW there has to be a better way than that!

But here's what I got to anyway:

Code:
=SUMPRODUCT(--(VALUESHEET!$A$2:$A$1000={A Constant}),--(VALUESHEET!$B$2:$B$1000={A Constant}),--(ISERROR(MATCH(VALUESHEET!$C$2:$C$1000*1,CONTROLSHEET!$A$2:$A$500,0))),VALUESHEET!$D$2:$D$1000)+SUMPRODUCT(COUNTIFS(VALUESHEET!$C$2:$C$1000,CONTROLSHEET!$B$2:$B$500,VALUESHEET!$B$2:$B$1000,{A CONSTANT},VALUESHEET!$A$2:$A$1000,{A CONSTANT}),--(LEFT(CONTROLSHEET!$B$2:$B$500,1)<>"O"),CONTROLSHEET!$C$2:$C$500)

I'm all eyes for anything you guys have up your sleeves to improve.

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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