where “color” (C5:C15) and “qty” (D5:D15) are named ranges.

Example

When F5 is selected, the following dropdown appears:

When the user makes a selection, the correct sum is returned. The named ranges “color” (C5:C15) and “qty” (D5:D15) are for convenience only. The formula in G5 performs a conditional sum based on the current dropdown selection in F5. The outermost function is an IF statement, which checks if the selection is “all”: If so, the formula returns the sum of quantity column as a final result. If F5 is any value except “all” (i.e. “red”, “blue”, or “green”), the logical test returns FALSE and IF routes the formula to the SUMIF function: SUMIF calculates a conditional sum based on the value in F5 and returns the result.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.