There is no easy way and no formula. VBA will be required. The best solution I saw - too long ago now to remember where - used recursion. It was only a dozen or two lines of code and worked quickly and very well. It was limited to about 2 dozen input values however, 'cause after that it took 'forever'. HTH