Alf's code in post #3 shows how to set up the loop. If that Solver model works, then it seems like that code should also work.
Do you or Alf know what happens when Solver is called from VBA and it encounters an error? I rarely if ever call Solver from VBA, and several of my Solver runs encountered the function's asymptote (#Div/0 error), and I wonder if that could cause Solver to exit without changing anything.
I would be curious to know if any of your solutions resulted in AP other than 5. My limited tests (without knowing typical values for AE or AI) all come to the solution where AP=5.
If it helps, I uploaded the simple spreadsheet I used to analyze this problem. The two algebraic solutions (assuming I did the algebra correctly) are given in rows 34 and 35 (I would expect that row 35 will always be the minimum solution). I note that the solutions obtained using the Solver model (row 40) are all the same as those in row 35, and the resulting values for AP are all 5. I included a chart that shows the basic shape of AP as a function of AJ (calculated in rows 4:27).
Bookmarks