You say that you have a model. With a model in place, the overall process I would expect for this:
1) Define what "optimize" means in the context of my model. Is it, as Richard guessed, maximum profit? Or maybe minimum cost? or something else? Once I know what I mean by "optimize", make sure I am calculating the appropriate "objective function" that represents that optimum somewhere in the spreadsheet.
2) This might be more math than programming, but then I would expect to spend some time exploring the behavior of the objective function. Does the OF have multiple local optima that can confuse some algorithms or is there only one optimum? Does the OF continuously increase or decrease?
3) Once I have some feel for the behavior of the OF, then I can look at possible algorithms for finding the optimum. Perhaps my efforts in 2 allow me to use what I learned in calculus about finding optima and I can take a few partial derivatives and come up with a closed form solution. Or I see, as Richard guessed in a max profit scenario, that max profit will occur at max sales/max capacity, so you can simply use that. Or some other strategy. Or maybe, after all other options have been discarded, I decide, like you, that a brute force "try every possible input combination" is the only way to find the optimum.
4) Then I start programming my chosen algorithm.
Without knowing anything about your model or your desired OF, it is difficult to do step 2 and, therefore, make any solid recommendations. If you are committed to the brute force try every possible input approach, I have this thread that talks a little about generating permutations in Excel and VBA: https://www.excelforum.com/tips-and-...thout-vba.html Assuming that your main question is about how to generate permutations, that should help with that part of the programming. Of course, one of the goals of this kind of programming is to find more efficient algorithms than brute force algorithms, so it is probably worth some effort to identify better algorithms.
Bookmarks