Need help automating pro-rata order allocation sheet so quantities and average prices match

psulion01

Board Regular
Joined
Sep 25, 2002
Messages
127
Here's my dilemma... Occasionally I have a handful of stock orders that are grouped together and need to be allocated on a pro-rata basis. All share allocations need to be whole numbers and each client's average price needs to be the same (to 4 decimals). If I don't force the share rounding in my sheet (using the ROUND function) then my average prices match up, but totaling the shares by hand result in missing/too many shares (since excel is calculating using decimals, i.e 15.234352 shares while my manual calculation by hand only counts 15 shares). As a result, getting the share totals to match by using ROUND will result in all average prices being mismatched.

I currently correct this through trial and error, adding and removing shares on the sheet until all totals tie out and all average prices match. What I need help with is some type of code that will be able to loop through and determine the correct whole share amounts needed to get all totals (on right and bottom) to match while also yielding an average price that matches to 4 decimal places.

Here's a sample sheet... can anyone point me in the right direction? I can make an attempt to code things, but my math skills are failing me and I'm not sure what type of calculations should be done to 'automate' my existing trial and error process to identify the correct share quantities.

Thanks!

Allocation (2).xlsx
ABCDEFGHI
4ClientAClientBClientCClientDClientETotal
5Shares4923666936243
6%ofAllocation0.2016460.0946500.2716050.2839510.148148100%
7PriceQuantity
810326399532
910.016513618181065
1010.022001102
1110.0347941313746
1210.04122133211
1310.045112133211
1410.058212218
1510.06245277425
1610.075122133211
1710.16112217
1810.125143144214
1910.155101114
2010.175101114
21
22243TotalShares4721676738240
2310.0402AveragePrice10.040710.035010.039010.039010.041810.0394
Sheet1
 

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.
Try the formatting, do not use the round function, format the shares allocated area to display integer, Cell format>custom> use this symbol # to show the integer.


Excel Workbook
ABCDEFGHI
1Client*AClient*BClient*CClient*DClient*ETotal
2Shares4923666936243
3%*of*Allocation0.201646090.094650210.2716050.2839510.148148
4PriceQuantityNot formattedFormattedFormattedFormattedNot formatted
510326.45267493994.74074132
610.016513.1069959618189.6296365
710.0220.40329218110.2962962
810.03479.47736626413136.96296347
910.04122.419753091331.77777812
1010.045112.2181071331.6296311
1110.0581.613168721221.1851858
1210.06244.839506172773.55555624
1310.075122.419753091331.77777812
1410.161.209876541220.8888896
1510.125142.823045271442.07407414
1610.1551.00823045110.7407415
1710.1751.00823045110.7407415
18
19243Total*Shares4923666936243
2010.0402Average*Price10.040710.03510.03910.03910.041810.0394
Sheet3
 
Upvote 0
Sorry it's not that simple. I can't have partial shares allocated to clients, so the decimals need to go. I have to either round up or down to whole numbers. This is why the average prices work when i'm not rounding (because the fractional shares aren't being throw away), but don't work when I round and force the whole numbers. Follow?
 
Upvote 0

Forum statistics

Threads
1,224,593
Messages
6,179,791
Members
452,942
Latest member
VijayNewtoExcel

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