SUMIFS, with specific value or ALL entries

alketrazz

New Member
Joined
Nov 13, 2013
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hi

I have this formula

VBA Code:
=SUM(SUMIFS(Data!$F:$F,Data!$P:$P,VolumePlan!$G45,Data!$O:$O,IF(nStockType="ALL",{"GBC","GBN","STK","VOR"},nStockType),Data!$N:$N,IF(nUnit="ALL",{2,4},nUnit)))

This should sum the values in column F

Column P where the value = to column G45

Column O where the value is either GBC, GBN, STK, VOR, or if all selected, include any of the values in the sum

Column N where the value is either 2 or 4, or if all selected, include any of the values in the sum

This is returning nothing. if I exclude the column O part or the column N part it works, but having both, doesn't work.


The other way I thought of doing this was with SUMPRODUCT, but that then relies on knowing how many rows there are as can't reference the entire column.

Any ideas ?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

With two arrays one has to be vertical & the other horizontal.
Try
Excel Formula:
=SUM(SUMIFS(Data!$F:$F,Data!$P:$P,VolumePlan!$G45,Data!$O:$O,IF(nStockType="ALL",{"GBC","GBN","STK","VOR"},nStockType),Data!$N:$N,IF(nUnit="ALL",{2;4},nUnit)))
 
Upvote 0
Solution
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

With two arrays one has to be vertical & the other horizontal.
Try
Excel Formula:
=SUM(SUMIFS(Data!$F:$F,Data!$P:$P,VolumePlan!$G45,Data!$O:$O,IF(nStockType="ALL",{"GBC","GBN","STK","VOR"},nStockType),Data!$N:$N,IF(nUnit="ALL",{2;4},nUnit)))
Hi... Thanks, I will update my profile.

Thanks, that's perfect and working correctly now, so the only change was the ; making it a vertial array.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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