Absolute Reference - Change absolute range without manual intervention

Marklarbear

Board Regular
Joined
Nov 6, 2003
Messages
119
Office Version
  1. 365
Platform
  1. Windows
Hi brains trust

Looking for assistance with the following formula in Sheet2 cell F2 (the formula calculates a weighted Average Handle Time):

=IFERROR(SUMPRODUCT(('Sheet1'!$G$2:$G$53=C2)*('Sheet1'!$E$2:$E$53)*('Sheet1'!$B$2:$B$53=B2)*('Sheet1'!$F$2:$F$53))/SUM(('Sheet1'!$G$2:$G$53=C2)*('Sheet1'!$E$2:$E$53)),0)

The formula works the way it is intended to, however, is there a way to 'progress' the absolute range references by 51 rows automatically?

The spreadsheet that I have inherited has data that goes across several years. the number of rows I need to look at in total on sheet1 is 74000. The date changes every 51 rows.... so at the moment i'm manually changing the absolute reference range by 51 every time the date changes. This is a very slow process....


ie on Sheet2, in cell F52 the formula changes to:

=IFERROR(SUMPRODUCT(('Sheet1'!$G$54:$G$105=C52)*('Sheet1'!$E$54:$E$105)*('Sheet1'!$B$54:$B$105=B52)*('Sheet1'!$F$54:$F$105))/SUM(('Sheet1'!$G$54:$G$105=C52)*('Sheet1'!$E$54:$E$105)),0)

and in cell F102 the formula changes to:

=IFERROR(SUMPRODUCT(('Sheet1'!$G$106:$G$157=C102)*('Sheet1'!$E$106:$E$157)*('Sheet1'!$B$106:$B$157=B102)*('Sheet1'!$F$106:$F$157))/SUM(('Sheet1'!$G$106:$G$157=C102)*('Sheet1'!$E$106:$E$157)),0)

and so on.....

Below are samples how sheet1 and sheet2 are set up (apologies as work security protocols wont allow xl2bb):

Sheet1:
1725330393799.png



Sheet2:
1725330437128.png


As always - any help is greatly appreciated....
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Need to test the formula with actual sample...
Can you attach spreadsheet, using XL2BB or gg drive?
 
Upvote 0
Dynamic formula for 365 version.
In Sheet2 cell F2
Excel Formula:
=LET(a,BYROW(K2:K2000,LAMBDA(ra,2+INT((ROWS($K$2:ra)-1)/50)*52)),b,BYROW(K2:K2000,LAMBDA(rb,53+INT((ROWS($K$2:rb)-1)/50)*52)),c,C2:C2000,d,B2:B2000,MAP(a,b,c,d,LAMBDA(sa,sb,sc,sd,SUMPRODUCT(((INDEX(Sheet1!$G:$G,sa):INDEX(Sheet1!$G:$G,sb))=sc)*((INDEX(Sheet1!$B:$B,sa):INDEX(Sheet1!$B:$B,sb))=sd)*(INDEX(Sheet1!$E:$E,sa):INDEX(Sheet1!$E:$E,sb))*(INDEX(Sheet1!$F:$F,sa):INDEX(Sheet1!$F:$F,sb)))/SUMPRODUCT(((INDEX(Sheet1!$G:$G,sa):INDEX(Sheet1!$G:$G,sb))=sc)*((INDEX(Sheet1!$B:$B,sa):INDEX(Sheet1!$B:$B,sb))=sd)*(INDEX(Sheet1!$E:$E,sa):INDEX(Sheet1!$E:$E,sb))))))
 
Upvote 1
Solution
Dynamic formula for 365 version.
In Sheet2 cell F2
Excel Formula:
=LET(a,BYROW(K2:K2000,LAMBDA(ra,2+INT((ROWS($K$2:ra)-1)/50)*52)),b,BYROW(K2:K2000,LAMBDA(rb,53+INT((ROWS($K$2:rb)-1)/50)*52)),c,C2:C2000,d,B2:B2000,MAP(a,b,c,d,LAMBDA(sa,sb,sc,sd,SUMPRODUCT(((INDEX(Sheet1!$G:$G,sa):INDEX(Sheet1!$G:$G,sb))=sc)*((INDEX(Sheet1!$B:$B,sa):INDEX(Sheet1!$B:$B,sb))=sd)*(INDEX(Sheet1!$E:$E,sa):INDEX(Sheet1!$E:$E,sb))*(INDEX(Sheet1!$F:$F,sa):INDEX(Sheet1!$F:$F,sb)))/SUMPRODUCT(((INDEX(Sheet1!$G:$G,sa):INDEX(Sheet1!$G:$G,sb))=sc)*((INDEX(Sheet1!$B:$B,sa):INDEX(Sheet1!$B:$B,sb))=sd)*(INDEX(Sheet1!$E:$E,sa):INDEX(Sheet1!$E:$E,sb))))))
Hey K - I don't completely understand this magic that you have in the formula, but it works perfectly!
thankyou greatly
 
Upvote 0
but it works perfectly!
:unsure: Just checking .. are you sure?
Is there something wrong with my sample data?

For a small test, this is all I have in Sheet1

Marklarbear.xlsm
BCDEFG
1
230/05/2022A11A
330/05/2022B12A
430/05/2022X13B
531/05/2022B14A
631/05/2022K15B
7
8
Sheet1


In Sheet2 I have your formula in column F, the post 5 formula in column G and a new suggestion in column H
The new formula matches your results for this small sample (but would need further careful checking).

Marklarbear.xlsm
BCFGH
1
230/05/2022A11.51
330/05/2022B1.531.5
431/05/2022C0#DIV/0!0
Sheet2
Cell Formulas
RangeFormula
G2:G2000G2=LET(a,BYROW(K2:K2000,LAMBDA(ra,2+INT((ROWS($K$2:ra)-1)/50)*52)),b,BYROW(K2:K2000,LAMBDA(rb,53+INT((ROWS($K$2:rb)-1)/50)*52)),c,C2:C2000,d,B2:B2000,MAP(a,b,c,d,LAMBDA(sa,sb,sc,sd,SUMPRODUCT(((INDEX(Sheet1!$G:$G,sa):INDEX(Sheet1!$G:$G,sb))=sc)*((INDEX(Sheet1!$B:$B,sa):INDEX(Sheet1!$B:$B,sb))=sd)*(INDEX(Sheet1!$E:$E,sa):INDEX(Sheet1!$E:$E,sb))*(INDEX(Sheet1!$F:$F,sa):INDEX(Sheet1!$F:$F,sb)))/SUMPRODUCT(((INDEX(Sheet1!$G:$G,sa):INDEX(Sheet1!$G:$G,sb))=sc)*((INDEX(Sheet1!$B:$B,sa):INDEX(Sheet1!$B:$B,sb))=sd)*(INDEX(Sheet1!$E:$E,sa):INDEX(Sheet1!$E:$E,sb))))))
H2:H2000H2=BYROW(B2:C2000,LAMBDA(rw,LET(ary,INT((ROW(rw)-1)/50)*52+SEQUENCE(52,,2),g,INDEX(Sheet1!G:G,ary),e,INDEX(Sheet1!E:E,ary),IFERROR(SUMPRODUCT((g=INDEX(rw,2))*e*(INDEX(Sheet1!B:B,ary)=INDEX(rw,1))*INDEX(Sheet1!F:F,ary))/SUM((g=INDEX(rw,2))*e),0))))
F2:F4F2=IFERROR(SUMPRODUCT((Sheet1!$G$2:$G$53=C2)*(Sheet1!$E$2:$E$53)*(Sheet1!$B$2:$B$53=B2)*(Sheet1!$F$2:$F$53))/SUM((Sheet1!$G$2:$G$53=C2)*(Sheet1!$E$2:$E$53)),0)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,257
Messages
6,177,475
Members
452,781
Latest member
Latlonchy

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