VBA Solver help needed

Kernkraft

Board Regular
Joined
Jul 26, 2009
Messages
68
Hello, I added the reference Solver in tools/references which cleared up one problem. Now I have another.

I cannot get the ValueOf portion of the code to reference the cell I would like to set another cell equal to... essentially it skips over it.

I've tried to name the cell, reference it outright by using ValueOf:=Range("C3") or ValueOf=Range("trgA") ... no dice, it will not reference the cell.

Code:
Sub Solver3()
'
'
SolverReset
SolverOk SetCell:="$E$23", MaxMinVal:=3, ValueOf:=Range("trgA"), ByChange:="$E$11:$E$16,$E$18:$E$22"
SolverSolve True
End Sub
Any help would be greatly appreciated.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I should also mention that I tried Peltier's version, but have no idea how to reference a particular cell for which I want the value to equal.

Code:
Sub Solver2()
'
'
'
    Application.Run "SolverReset"
    Application.Run "SolverAdd", "$E$23", 3, "trgA"
    Application.Run "SolverOk", "$E$23", 3, "trgA", "$E$11:$E$16,$E$18:$E$22"
    Application.Run "SolverSolve", True
End Sub
 
Upvote 0
Does trgA change in reponse to any of the changing cells? That's not allowed.
 
Upvote 0
Does trgA change in reponse to any of the changing cells? That's not allowed.

No it does not, it's the cell I want to be able to physically manipulate within the spreadsheet and then based on that change, I want it to change $E$11:$E$16,$E$18:$E$22 so that E23 is equal to trgA
 
Upvote 0
You're welcome, glad it worked for you.
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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