Microsoft Excel itself is more interesting when it comes to formulas, so many things are very easy to do with VBA but are challenging with formulas. so we have got one challenge like that. have a look.
Above image is explaining what needs to get done. so we need sum of highlighted cells and let me tell you why those cells are highlighted. Rule is to include all the cells while sum is less or equal to max value for that row. Highlighting is just to show the cells we need to sum, this is color is nowhere related to the formulas.
Please write your comment/Result formulas in the comment section