Sum 2D array based on dynamic year array and dynamic company array

vampsthevampyre

New Member
Joined
Apr 29, 2016
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Afternoon All,

I though I was finished with my dividend spread sheet but now I'm trying to calculate the 3 year dividend CAGR. I have an import routine that looks up Yahoo finance historic dividend payments and returns a sheet that I generate an array from. A small section of the array is shown below.

What I'm looking to do is calculate the dividends paid for the years in cells C5 - E5 (these are dynamically created based on the current year) using the accounts in cells B6-B36 (again dynamically generated). The actual table is much larger but I'm sure you get the idea.

The final table hopefully would have the 34 companies down left hand side and the previous three years across the top. I'm getting stuck because its an array criteria range using an array as a criteria

Any help would be appreciated

Regards

Ian

Bulk Dividend Downloader.xlsm
ABCDEFGHIJKLMNOPQRST
1
2Rows1826
3Columns34ANP.LBA.LBATS.LBME.LCGS.LCRDA.LCSN.LDCC.LDGE.LGLEN.LGSK.LHLMA.LHFG.L
412328/06/20180048.84.8000000000
520222021202029/06/20180000000000000
6ANP.L#N/A30/06/20180000000000000
7BA.L01/07/20180000000000000
8BATS.L02/07/20180000000000000
9BME.L03/07/20180000000000000
10CGS.L04/07/20180000000000000
11CRDA.L05/07/20180000000000000
12CSN.L06/07/20180000000000000
13DCC.L07/07/20180000000000000
14DGE.L08/07/20180000000000000
15GLEN.L09/07/20180000000000000
16GSK.L10/07/20180000000000000
17HLMA.L11/07/20180000000000000
18HFG.L12/07/20184.500011.120000008.970
19LGEN.L13/07/20180000000000000
20LMP.L14/07/20180000000000000
21MGNS.L15/07/20180000000000000
22MONY.L16/07/20180000000000000
23MNG.L17/07/20180000000000000
24NG.L18/07/20180000000000000
25PHNX.L19/07/20180000000000000
26PHP.L20/07/20180000000000000
27PSN.L21/07/20180000000000000
28RIO.L22/07/20180000000000000
29RWS.L23/07/20180000000000000
30SGE.L24/07/20180000000000000
31SRE.L25/07/20180000000000000
32SPX.L26/07/20180000000000000
33KETL.L27/07/20180000000000000
34TND.L28/07/20180000000000000
35THRL.L29/07/20180000000000000
36ULVR.L30/07/20180000000000000
Sheet268
Cell Formulas
RangeFormula
B2B2=COUNTA('Collated Dividends'!A:A)
B3B3=COUNTA('Collated Dividends'!1:1)
H3:AO3H3=OFFSET('Collated Dividends'!B1,,,,Sheet268!B3)
G4:G1829G4=OFFSET('Collated Dividends'!A2,,,Sheet268!B2)
H4:AO1829H4=OFFSET('Collated Dividends'!B2,,,Sheet268!B2,Sheet268!B3)
C4:E4C4=SEQUENCE(,3)
C5:E5C5=YEAR(TODAY())-C4#
B6:B39B6=TRANSPOSE(H3#)
C6C6=SUMPRODUCT(H4#*(H3#=B6#)*(YEAR(G4#)=C5#))
Dynamic array formulas.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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’)
 
Upvote 0
Ok, in C6 dragged across.
Excel Formula:
=BYROW($B$6#,LAMBDA(br,SUM(IF((YEAR($G$4#)=C5)*($H$3#=br),$H$4#,0))))
 
Upvote 1
Solution
@Fluff as usual thanks for a perfect solution, just a quick question is there any way at the moment to use two dynamic arrays so you don't have to drag across. I think I know the answer already from your reply and the fact that you didn't offer it up as a solution but surprised that excel doesn't have this as an option yet.

As always thanks for your help

Best Regards

Ian
 
Upvote 0
You could use
Excel Formula:
=MAKEARRAY(ROWS(B6#),COLUMNS(C5#),LAMBDA(r,c,SUM(IF((YEAR(G4#)=INDEX(C5#,,c))*(H3#=INDEX(B6#,r)),H4#))))
But it's likely to be very slow.

Also please don't forget to update your profile to show the version you are using. It saves people from having to ask. ;)
 
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