Dynamic Array needed

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,177
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have VBA for this but I am looking to solve this with your help with a Dynamic Array. I am looking for a Dynamic array of employees and schools. Each x represents 0.2 for a day. Sometimes a person will be at multiple schools in a day. So if the employee goes to 2 schools in a day then it would be 0.1 for the first school and 0.1 for the second school.

For employee 111
IDLast NameFirst NameSchoolMTWTHF
111​
AAAAWashingtonxx
111​
AAAALincolnxxxxx

In this example 111 at School Washington Works W and TH. Wednesday is also at Lincoln and Thursday at Lincoln so 0.1 for W and 0.1 for TH = 0.2.
At Lincoln M 0.2, T 0.2, W 0.1, TH 0.1, F 0.2 = 0.8

Book1
ABCDEFGHIJ
1IDLast NameFirst NameSchoolMTWTHF
2111AAAAWashingtonxx0.2
3111AAAALincolnxxxxx0.8
4222BBBBFordx0.1
5222BBBBWashingtonxxxxx0.9
6333CCCCHardingxxxxx1
7444DDDDCentralxxx0.233333333
8444DDDDLincolnxxxxx0.633333333
9444DDDDFordxx0.133333333
10555EEEEJohnsonxxx0.4
11555EEEEKennedyxxxx0.4
12555EEEERooseveltxx0.2
Sheet1
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
How about
Fluff.xlsm
ABCDEFGHIJ
1IDLast NameFirst NameSchoolMTWTHF
2111AAAAWashingtonxx0.2
3111AAAALincolnxxxxx0.8
4222BBBBFordx0.1
5222BBBBWashingtonxxxxx0.9
6333CCCCHardingxxxxx1
7444DDDDCentralxxx0.23333333
8444DDDDLincolnxxxxx0.63333333
9444DDDDFordxx0.13333333
10555EEEEJohnsonxxx0.4
11555EEEEKennedyxxxx0.4
12555EEEERooseveltxx0.2
13
Data
Cell Formulas
RangeFormula
J2:J12J2=BYROW(A2:I12,LAMBDA(br,SUM(0.2/BYCOL(FILTER($E$2:$I$100,$A$2:$A$100=TAKE(br,,1)),LAMBDA(bc,SUM(--(bc="x"))))*(TAKE(br,,-5)="x"))))
Dynamic array formulas.
 
Upvote 0
Fluff
It is 95% there! It gives me an error when not all 5 are filled in like below.

1008zzzzThomas Hookerxx
1008zzzzWashingtonxxx
 
Upvote 0
How about
Excel Formula:
=BYROW(A2:I12,LAMBDA(br,SUM(IFERROR(0.2/BYCOL(FILTER($E$2:$I$100,$A$2:$A$100=TAKE(br,,1)),LAMBDA(bc,SUM(--(bc="x"))))*(TAKE(br,,-5)="x"),0))))
 
Upvote 0
How about
Excel Formula:
=BYROW(A2:I12,LAMBDA(br,SUM(IFERROR(0.2/BYCOL(FILTER($E$2:$I$100,$A$2:$A$100=TAKE(br,,1)),LAMBDA(bc,SUM(--(bc="x"))))*(TAKE(br,,-5)="x"),0))))
Beautiful!!! Thank you very much. Worked great. I appreciate all of the help!!!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Another option:
The more readable (col J - LET function)
Or the condensed (col K)


Book1
ABCDEFGHIJK
1IDLast NameFirst NameSchoolMTWTHF
2111AAAAWashingtonxx0.20.2
3111AAAALincolnxxxxx0.80.8
4222BBBBFordx0.10.1
5222BBBBWashingtonxxxxx0.90.9
6333CCCCHardingxxxxx11
7444DDDDCentralxxx0.2333330.233333
8444DDDDLincolnxxxxx0.6333330.633333
9444DDDDFordxx0.1333330.133333
10555EEEEJohnsonxxx0.40.4
11555EEEEKennedyxxxx0.40.4
12555EEEERooseveltxx0.20.2
Sheet4
Cell Formulas
RangeFormula
J2:J12J2=LET(cId, A2, id, $A$2:$A$12, d, ($E$2:$I$12<>"")*1, r, (E2:I2<>"")*1, fd, FILTER(d,id=cId), SUM(0.2/BYCOL(fd,LAMBDA(x,SUM(x)))*r) )
K2:K12K2=SUM(0.2/BYCOL(FILTER(($E$2:$I$12<>"")*1,$A$2:$A$12=A2),LAMBDA(x,SUM(x)))*(E2:I2<>""))
 
Upvote 0
Not sure if you saw post#3 as your formula will have the same problem as mine did.
 
Upvote 0
You are right. My mistake.

here is the correction:

Book1
ABCDEFGHIJK
1IDLast NameFirst NameSchoolMTWTHF
2111AAAAWashingtonxx0.30.3
3111AAAALincolnxxx0.50.5
4222BBBBFordx0.10.1
5222BBBBWashingtonxxxxx0.90.9
6333CCCCHardingxxxxx11
7444DDDDCentralxxx0.2333330.233333
8444DDDDLincolnxxxxx0.6333330.633333
9444DDDDFordxx0.1333330.133333
10555EEEEJohnsonxxx0.40.4
11555EEEEKennedyxxxx0.40.4
12555EEEERooseveltxx0.20.2
Sheet4
Cell Formulas
RangeFormula
J2:J12J2=LET(cId, A2, id, $A$2:$A$12, d, ($E$2:$I$12<>"")*1, r, (E2:I2<>"")*1, fd, FILTER(d,id=cId), SUM(IFERROR(0.2/BYCOL(fd,LAMBDA(x,SUM(x)))*r,0)) )
K2:K12K2=SUM(IFERROR(0.2/BYCOL(FILTER(($E$2:$I$12<>"")*1,$A$2:$A$12=A2),LAMBDA(x,SUM(x)))*(E2:I2<>""),0))
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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