Run-Time Error 1004: Error in Formula
Before you use this function, you need to load the Solver Add-In using the Add-In manager. To load the Solver Add-In, follow these steps:
- On the Tools Menu, click Add-Ins and click to select the Solver Add-In check box.
- If the Solver Add-In doesn't appear in the Add-Ins Available box, click the Browse button, select Solver.xla in the \Excel\Library\Solver folder, and then click OK.
Sample Visual Basic ProcedureThe following macro shows an example of how to call the Solver.Ok macro using R1C1 notation:
- In a new Microsoft Excel Workbook, on the Insert menu, point to Macro, click Module, and then type the following macro code:
ActiveCell.Formula = "=a1+b1"
' Solver.Ok Parameters
Set_Cell = Range("C1").Address(True, True, xlR1C1, True)
Max_Min_Val = 3
Value_Of = 21
By_Changing = Range("a1:b1").Address(True, True, xlR1C1, True)
& Set_Cell & "," & Max_Min_Val & "," & Value_Of & "," & _
By_Changing & ")"
- On the Tools Menu, click Macro, select the SolverOkDemo Macro from the list, and then click the Run Button to run the macro.
- Select sheet1.
- Select cell C1.
- Insert the formula =A1+B1 in cell C1.
- Places the found solution in Cells A1 and B1.
- Solver's dialog box will appear, indicating that it found a solution.
- Click OK.
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:
For more information about Solver.OK in Microsoft Excel version 5.0, choose Contents in help, Click Reference Information, and then choose the Search button and type:
For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
Id. de artículo: 153442 - Última revisión: 06/22/2014 - Revisión: 1