A newsgroup question read:

I'm going to simplify this from my real data, but I have a pipe supplier who will only sell pipes in certain quantities to make shipping manageable. So you have to buy a full truck load of pipe to begin with, and after that anywhere between a half and full load.

A full load is 10 pipes. So that's the minimum order. After that you have to order at LEAST another half load, so 5 more pipes. Between that and the next full load, they don't care. They just don't want to ship a truck that's less than half full.

So the pipe quantities you can buy in are: 10...15,16,17,18,19,20...25,26,27,28,29,30...35...etc

How could I write a formula that will automatically round me up to the next approved quantity of pipe?

My proposed general solution:

=ROUNDUP(IF(A6<=0,0,IF(A6<=$B$1*$B$2,$B$1*$B$2,$B$1*INT(A6/$B$1)+IF(MOD(A6,$B$1)>0,MAX(MOD(A6,$B$1),$B$1*$B$3),0))),0)

Please read my Disclaimer.