Unfortunately I won't be able to send the front-end / interface related to this, as it contains some company - sensitive informtaion. However, the code below is executed through a button and the user is promted for a "target value" which must be matched subject to certain constraints that have been included.
Hope the majority of this is self explainitory, however, please let me know if you require any additional details. Basically I would like the "trial solutions" not to be displayed, but rather I would prefer it if Solver output the most optimal solution without being promted for it.
Thanks
Option Explicit</SPAN>
Sub RUNSOLVER()</SPAN>
Application.Run "SolverReset"</SPAN>
Dim TARGET As Variant</SPAN>
TARGET = Application.InputBox("ENTER TARGET % IN A DECIMAL FORMAT (E.G. A TARGET OF 0.25% SHOULD BE ENTERED AS 0.0025")</SPAN>
If Not IsNumeric(TARGET) Then</SPAN>
MsgBox "Please Enter a Valid Target Value"</SPAN>
End If</SPAN>
If TARGET > 1 Then</SPAN>
MsgBox "Please Enter a Target Value < 1"</SPAN>
End If</SPAN>
On Error GoTo 0</SPAN>
Application.Run "SolverAdd", "$U$46", 2, "$C$4"</SPAN>
Application.Run "SolverOk", "$G$86", 3, TARGET, "$B$50,$B$52"</SPAN>
Application.Run "SolverSolve", UserFinish:=False</SPAN>
Application.DisplayAlerts = False</SPAN>
On Error GoTo 0</SPAN>
Dim RESULT As Variant</SPAN>
RESULT = Application.Run("SolverSolve", True)</SPAN>
If RESULT <= 3 Then</SPAN>
MsgBox "SOLUTION FOUND", vbInformation, "SOLUTION FOUND"</SPAN>
ElseIf RESULT = 13 Then MsgBox "ERROR PLEASE CHECK PARAMETERS ENTERED AND TRY AGAIN"</SPAN>
Else: MsgBox "Solver was unable to find a solution.", vbExclamation, "SOLUTION NOT FOUND"</SPAN>
End If</SPAN>
End Sub</SPAN>