View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove Harlan Grove is offline
external usenet poster
 
Posts: 733
Default adding multiple vlookup results

"Herbert Seidenberg" wrote...
Taking Fomo's second post as a reference, I assume that your range
"Dollars" refers to a 20+ column by 13+ row array.


No idea. And since I wasn't responding to you, don't much care what
transpired in the other branch of this discussion thread.

I was referring to the OP's original formulas, which I didn't quote
but which Alan Beban did, namely

..=vlookup(3,dollars,2,false)+vlookup(5,dollars, false)


which is an error since the second VLOOKUP call lacks 4 arguments, but
it shows the OP wants to sum values from different rows in a range
named dollars, and

..=vlookup({3,5},dollars,2,false)


which makes it clearer that the OP wants values from column 2 of
dollars.

If you want to roll the other branch into this one, feel free.

A named set of Territory numbers (13+) is on the left side.
I don't see any reference to Territory in your formula.


If you want to add one, feel free. Note that the OP's follow-up to
which you responded included the statement

..using 13 territory numbers specified in either another range or int he
..formula itself......like:
..
..=vlookup(terrs,lookuptable,4,false) or
..
..=vlookup({13,15,17,18},lookuptable,4,false)


So the OP seems to be OK hardcoding the territory numbers. Maybe not
best practice, but feel free to modify my formulas yourself. Anyway,
(1) using the name terrs appeared in a different branch, so not
necessarily relevant in the branch in which I was responding, and (2)
the OP seems not to *require* it anyway.

The OP wants to select a subset of 4 territories.
Assuming you meant "Territory" instead of "Dollars"
INDEX(Territory,0,1)={3,5,7,9} does not work since the ranges are not
equal.


You're failing to distinguish between the setup you used in your
formula, in which you assumed a multiple-row, single-column range
named TerrSet and the array constant I used, which was SINGLE-ROW,
MULTIPLE-COLUMN. Orientation makes all the difference when you pay
enough attention to spot it.

You obviously didn't bother to test my formula. Calling INDEX with 2nd
argument 0 returns all rows in the specified column, so effectively a
multiple-row by single-column array. OTOH, {3,5,7,9} is a single-row
by multiple-column array. You seem ignorant of the fact that when
Excel performs arithmetic on an M-by-1 array and a 1-by-N array, it
produces an M-by-N array. For example,

{1;10;100;1000}*{1,2,3} = {1,2,3;10,20,30;100,200,300;1000,2000,3000}

that is, {1;10;100;1000} is treated like
{1,1,1;10,10,10;100,100,100;1000,1000,1000} and {1,2,3} is treated
like {1,2,3;1,2,3;1,2,3;1,2,3}. Try stepwise evaluatation of my
formula to see how it works. You might learn something.

Besides, the OP wants the subset of territories in a separately named
range, presumably not padded with 0s.


Didn't seem to be a requirement, just an alternative. Still, if the OP
has one range named dollars with 1st column containing territory
codes, and another range named terrs containing just the territory
codes s/he wants to select, then another alternative would be

=SUMPRODUCT((COUNTIF(terrs,INDEX(dollars,0,1)))*IN DEX(dollars,0,4))

in which dollars refers to something like the combination of your
TerrT and ArrayA ranges and terrs refers to something like your
TerrSet range. I'll leave it up to you to figure out how
COUNTIF(terrs,INDEX(dollars,0,1)) works.