I have a collection of records, each record has a total; I want to split the whole collection up into sets, each set can only hold so much (20 in the example).

I have thought about two methods so far and I've shown a simple representation below:

Sets are separate:
![](https://i.stack.imgur.com/FmKqg.png)

* set1 has the first two since 5+10=15 (the next 12 will put it over 20).
* set2 will have the next two since 12+7=19.

Another Idea I toyed with is just to add a set column onto the source data set:

![](https://i.stack.imgur.com/ZgGFE.png)

I'm trying to figure out an easy way to complete this using formula, if it's easier to complete in VBA I'll then go that route.

Thanks for the help, I've been thinking about this all week and don't even know what to search for.

\*\*Edit: I'm an idiot.