Having difficulty developing an excel function that will round a list of decimals, so that the sum of the whole numbers equals the original or a defined total.
Edit I guess one way to do it is writing a function that first searches for the largest numbers and rounds them to the nearest whole number. That whole number is then counted and the function moves on to the next, until the total count equals the target total.
The problem that I am running into is that if there are too many numbers that are closer to 0, then the function will never equal the target total. So what the function then needs to do is identify the largest decimals, round them up, count, and then move on to the next until the sum of the count is equal to the target total. The left over data can then round to 0.
Sorry, I hope this is clearer....
I am dealing with larger data sets where the totals of the rounded whole numbers have much larger deviations to the original total.
It would preferable if this could be accomplished with an excel function, otherwise I am also open to doing in VBA.
Thanks!
Edit 3: Here is an example data set:

