I need help to figure out algorithm in vb6 for creating groups of people given the total based on some rules. The groups need to be as even as possible. The Maximum people in a group is 8. The Minimum people in a group is 6. The groups need to be as close to the Maximum as possible.

So:
If the Total = 24 the algorithm will produce 3 Groups of 8

If the Total = 21 the algorithm will produce 3 Groups of 7
(not 2 groups of 8 and 1 group of 6)

If the Total = 26 the algorithm will produce 2 Groups of 7 and 2 groups of 6

I tried and failed to implement anything that works. Any help is greatly appreciated