Using VLOOKUP in array formulae

2016LM

New Member
Joined
Sep 9, 2016
Messages
18
Hi

Many thanks for taking the trouble to read this Thread.I’ve tried searching the forum for a similar problem / question, but to no avail,hence the new Thread.




I have a row of values (A5:A9, shownin black) I want to look-up (using VLOOKUP) in a small table (A1:B3, shown in red) and then sum thesefigures at the bottom of the table in cell B14 (shown in green).




[TABLE="class: grid, width: 100"]
<tbody>[TR]
[TD]1

[/TD]
[TD]7

[/TD]
[/TR]
[TR]
[TD]2

[/TD]
[TD]10

[/TD]
[/TR]
[TR]
[TD]3

[/TD]
[TD]12
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]7
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]7
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]12
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]12
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]10
[/TD]
[/TR]
[TR]
[TD]TOTAL
[/TD]
[TD]46
[/TD]
[/TR]
</tbody>[/TABLE]


Iappreciate I can do this using VLOOKUP in each of the cells adjoining the A5:A9 range then total with a SUM, whatI was wondering however was, is it possible to use VLOOKUP in an array formula? I tried using the following formula: {=SUM(VLOOKUP(A5:A9,$A$1:$B$3,2,TRUE)}which seems to sum the first value only.



I’mstill on the ‘array formula’ learning curve, and was hoping someone could pointout where my mistake is and / or whether what I’m trying to achieve is possiblewith array formulae?



Manythanks,



2016LM



 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Why do we get 46 as the sum? Do you mean this?

=SUMPRODUCT(SUMIFS($B$5:$B$9,$A$5:$A$9,$A$1:$A$3))
 
Upvote 0
Hi steve the fish,

Thanks for replying to my query. 46 is the summation of the numbers in the second column (shown in black); these have been looked-up from the table in red. Apologies I mistakenly quoted the total being is cell B14, when it should have stated B10. The table was included to show what I was trying to achieve with the array formula - I was effectively wanting to do away with having to look-up the numbers individually then summing then i.e. instead of the column with 7,7,12,12,10 and the 46, I would simply have the numbers to look-up (i.e. 1,1,3,3,2) and a total. Is this possible to do?

Apologies fo the untidiness of my initial post, I was having difficulty with the text editor.

Kind regards,
2016LM
 
Last edited:
Upvote 0
Hi,

Achieving this with VLOOKUP is possible, though not very efficient (nor syntactically easy to understand). Better is SUMIFS, i.e.:

=SUMPRODUCT(SUMIFS(B1:B3,A1:A3,A5:A9))

For the record:

=SUMPRODUCT(VLOOKUP(N(IF({1},A5:A9)),A1:B3,2,0))

where the entries in A5:A9 are assumed to be numeric, not text.

Regards
 
Upvote 0
Hi XOR LX

That's what I was after, brilliant thanks. Out of interest, could you explain what 'N(IF({1},A5:A9))' does please; I've never seen an IF command with a logical_test and either a TRUE or FALSE before?

Apologies to all, I've just realised that 46 should have been 48.

Kind regards,

2016LM
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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