PDA

View Full Version : SOLVEROK



willemeulen
01-15-2010, 01:58 AM
I have recorded following Solver VBA code

It works fine except I want to set the value to be referenced to cell Q56 (see highlighted), when I adjust the highlighted part to ValueOf:="$Q$56" it doesn't work anymore.

Secondly the code must be triggered when Cell E10 get to a value of 4 or 5 and cell R19=0
Cell R19 will display 1 up and untill all necessary data is completed for the calculations.

Sub Solveyman()
Range("R56").Select
ActiveCell.FormulaR1C1 = "0"
SolverReset
SolverOk SetCell:="$S$56", MaxMinVal:=3, ValueOf:="270.331", ByChange:="$R$56"
SolverSolve True

End Sub


Thanks

Bob Phillips
01-15-2010, 02:44 AM
Have you tried



ValueOf:=Range("Q56").Value

willemeulen
01-15-2010, 02:58 AM
Works a treat, thanks for that XLD!

Better idea for other question, I will create a cell which displays True or 1 depending if conditions are met stated in my first post (Cell A10 value is 4 or 5 and cell R19 is 0)

How do I trigger the macro when a specific cell is TRUE?

W

Bob Phillips
01-15-2010, 06:32 AM
Use the worksheet change or calculate event (depending pon how it is set).