View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Distribution loop

You could use division and the mod function. The mod function would tell
you the remainder which you would distribute 1 per bag until exhausted.

--
Regards,
Tom Ogilvy





"Martin" wrote in message
...
Dear all,

I have 4 bags and 4 apples and want to put 1 apple in each bag. Easy.

However when I have 3 apples and want to put them in the first 3 bags out

of
the 4 bags.

When I have 5 apples and want to put 4 into each bag and add the

additional
apple to the first bag.

The number of apples and the number of bags can change from case to case.
For example I could have 10 apples and 6 bags, 3 apples and 10 bags etc

How do I do this? Can I do it in the spreadsheet or do I need to produce a
macro?

Any help highly appreciated.

--
Regards,

Martin