Dynamic array in sumproduct function

FM89

New Member
Joined
Dec 1, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
hi all,

Trying to set up a sumproduct of two columns whereas one column needs to retrieve its data from another table. Below a simplified example whereas I'm looking for a solution for the green numbers:

1638351524150.png


1638351615694.png


The total in sheet 1 calculates the total EUR amount based on the conversion rates in sheet 2. Sheet 1 is in reality however significant with continuously lines being added, removed and changed. Also new currencies are regularly added to sheet 2. Looking for a formula for the green totals in sheet 1 which does not need alternation when changes are made or lines are added to one of the two sheets.

Thanks.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You could use Lookup, XLookup, or other alternatives.

T202112a.xlsm
ABCD
1Total59.46159.2
2EUR101010
3EUR101010
4USD101010
5USD101010
6GBP101010
7GBP101010
1a
Cell Formulas
RangeFormula
B1:D1B1=SUMPRODUCT(B2:B7,LOOKUP($A$2:$A$7,Sheet2!$A$2:$A$4,Sheet2!B2:B4))


T202112a.xlsm
ABCD
1
2EUR111
3GBP1.121.181.14
4USD0.850.870.82
Sheet2
 
Upvote 0
Welcome to the MrExcel board!

Adding to Dave's suggestion, I would choose XLOOKUP as a more efficient function and convert the data in the two sheets to formal tables if they are not already. That way you will get the automatic expansion/contraction of the relevant ranges in the formulas as you had requested.

Below, the table in Sheet2 I have named 'tblLookup' and the table in Sheet1 'tblData'

FM89.xlsm
ABCD
1CurrencyJanFebMar
2EUR111
3USD0.850.870.82
4GBP1.121.181.14
Sheet2


XL2BB shows 3 separate formulas below. You cannot drag the B1 formula right across row 1, but you can drag it from B1 to C1 then drag C1 to D1 (etc if you have more columns). That is a slight inconvenience but it only has to be done once. :)

FM89.xlsm
ABCDE
1Total59.461.059.2
2CurrencyJanFebMar
3EUR101010
4EUR101010
5USD101010
6USD101010
7GBP101010
8GBP101010
9
Sheet1
Cell Formulas
RangeFormula
B1B1=SUMPRODUCT(tblData[Jan],XLOOKUP(tblData[[Currency]:[Currency]],tblLookup[[Currency]:[Currency]],tblLookup[Jan],0))
C1C1=SUMPRODUCT(tblData[Feb],XLOOKUP(tblData[[Currency]:[Currency]],tblLookup[[Currency]:[Currency]],tblLookup[Feb],0))
D1D1=SUMPRODUCT(tblData[Mar],XLOOKUP(tblData[[Currency]:[Currency]],tblLookup[[Currency]:[Currency]],tblLookup[Mar],0))
 
Upvote 0
Solution
Thanks both. The lookup doesn't seem to work, it does not always matches the right currencies. xlookup works perfect, didn't knew this could be used on a entire column.
 
Upvote 0
"The lookup doesn't seem to work, it does not always matches the right currencies."

Check the help information for Lookup.
The Lookup works. Is your table or array sorted ascending?
 
Upvote 0
You're welcome. Thanks for the follow up. :)
 
Upvote 0

Forum statistics

Threads
1,214,800
Messages
6,121,641
Members
449,044
Latest member
hherna01

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