Solver Macro - Won't Allow Cell Reference in Code?

Nitro88

New Member
Joined
Oct 5, 2011
Messages
18
Excel 2010 on Windows 7

I am using an Excel spreadsheet with a simple solver macro.
The following macro works but when I change the Value Of:= to reference a cell in the worksheet it doesn't work any longer.

In the macro I want to have the "...Value Of:=0.13"... part of the instructions refer directly to a cell that can be changed (e.g. "...Value Of:="$D$100...") but the macro doesn't seem to work when I try this. Can the Value Of be dynamic? Am I just writing the macro incorrectly?

Sub Macro2()
'
' Macro2 Macro
'

'
SolverOk SetCell:="$D$108", MaxMinVal:=3, ValueOf:=0.13, ByChange:="$S$106", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$D$108", MaxMinVal:=3, ValueOf:=0.13, ByChange:="$S$106", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,203,610
Messages
6,056,294
Members
444,855
Latest member
archadiel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top