Distributing funds across multiple lines

Cr864

New Member
Joined
Dec 30, 2021
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Good afternoon! I was looking for some help here. I have an extremely large list of accounts with fees due (A11:C30). There will be multiple entries for each account number with different amounts due. I have a list of the accounts with the available funds that can be applied. (A3:B7).

What i would like to do is take the funds and for each fee, apply as much to that fee as possible then move to the next one so for instance in the range E11:F30 in my example you can see that the Account 1234 has 550 available, after allocating 50 to the fee in E12, F12 shows the remaining funds we'd have. Then continues through the listings with that account. In my data, all of the accounts will be grouped together but they will potentially have different numbers of fees/line items that need allocation.

In reality, there are about 7000 line items I need to go through with around 900 accounts. I was looking for some help with some VBA in excel that could help accomplish this?

Thank you all for any help you can provide! And if you need more context i'll be happy to provide it.

Test File.xlsx
ABCDEF
1Example
2
3AccountAvailable Funds
41234550
55678250
6901231000
745678910000
8
9
10
11Fees DueExpected Results
121234Fee 15050500
131234Fee 2250250250
141234Fee 3100100150
151234Fee 412510050
165678Fee 12525225
175678Fee 21515210
185678Fee 33030180
195678Fee 42001800
205678Fee 55000
2190123Fee 1100010000
2290123Fee 220000
2390123Fee 320000
2490123Fee 430000
2590123Fee 540000
2690123Fee 65000
27456789Fee 1500050005000
28456790Fee 2400040001000
29456791Fee 3100010000
30456792Fee 45000
Sheet4
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
MrExcelPlayground12.xlsx
ABCDEF
1Example
2
3AccountAvailable Funds
41234550
55678250
6901231000
745678910000
8
9
10
11Fees Due
121234Fee 15050500
131234Fee 2250250250
141234Fee 3100100150
151234Fee 412512525
165678Fee 12525225
175678Fee 21515210
185678Fee 33030180
195678Fee 42001800
205678Fee 55000
2190123Fee 1100010000
2290123Fee 220000
2390123Fee 320000
2490123Fee 430000
2590123Fee 540000
2690123Fee 65000
27456789Fee 1500050005000
28456789Fee 2400040001000
29456789Fee 3100010000
30456789Fee 45000
Sheet7
Cell Formulas
RangeFormula
E12:E30E12=MAX(0,C12+MIN(0,XLOOKUP(A12,$A$4:$A$7,$B$4:$B$7,0,0)-SUM(FILTER(C$12:C12,A$12:A12=A12))))
F12:F30F12=MAX(0,XLOOKUP(A12,$A$4:$A$7,$B$4:$B$7,0,0)-SUM(FILTER(C$12:C12,A$12:A12=A12)))


or

MrExcelPlayground12.xlsx
ABCDEF
1Example
2
3AccountAvailable Funds
41234550
55678250
6901231000
745678910000
8
9
10
11Fees Due
121234Fee 15050500
131234Fee 2250250250
141234Fee 3100100150
151234Fee 412512525
165678Fee 12525225
175678Fee 21515210
185678Fee 33030180
195678Fee 42001800
205678Fee 55000
2190123Fee 1100010000
2290123Fee 220000
2390123Fee 320000
2490123Fee 430000
2590123Fee 540000
2690123Fee 65000
27456789Fee 1500050005000
28456789Fee 2400040001000
29456789Fee 3100010000
30456789Fee 45000
Sheet7
Cell Formulas
RangeFormula
E12:F30E12=LET(a,XLOOKUP(A12,$A$4:$A$7,$B$4:$B$7,0,0)-SUM(FILTER(C$12:C12,A$12:A12=A12)),b,MAX(0,a),c,MAX(0,C12+MIN(0,a)),IF(SEQUENCE(1,2)=1,c,b))
Dynamic array formulas.
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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