Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default VBA Code for Solver

I am writing a simple program to use solver to asnwer a question. The user
interface will be on a spreadsheet, and I would like the user to adjust
certain parameters, then click a macro button which will call up solver and
"solve the problem". The problem is, I am trying to enable the user to
adjust the valueof parameter in solverok by changing a cell on the
spreadsheet, then clicking the button to get the answer. Unfortunately, that
"valueof" parameter does not appear to take a cell location. Can someone
suggest a simple workaround to make this work. Here is the macro code i am
using now.


SolverReset
SolverAdd cellref:="$I$4", relation:=1, formulatext:="$D$4/$D$2"
SolverAdd cellref:="$I$4:$I$8", relation:=3, formulatext:="0"
SolverAdd cellref:="$I$4", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$5", relation:=1, formulatext:="$D$5/$D$2"
SolverAdd cellref:="$I$5", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$6", relation:=1, formulatext:="$D$6/$D$2"
SolverAdd cellref:="$I$6", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$7", relation:=1, formulatext:="$D$7/$D$2"
SolverAdd cellref:="$I$7", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$8", relation:=1, formulatext:="$D$8/$D$2"
SolverAdd cellref:="$I$8", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$4", relation:=3, formulatext:="($D$4/$D$2)-4"
SolverOk SetCell:="$J$9", MaxMinVal:=3, valueof:=i, ByChange:="$I$4:$I$8"

SolverSolve Userfinish:=True
SolverFinish Keepfinal:=1


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA Code for Solver

Hi David,

I have used the Solver a few times, so I may not know all the finer
tricks. However, when I do use the Solver, I use the constraints as my
inputs to change the output. Is this your basic question? If so, set
the constraint values to specific cells in the worksheet, change the
values accordingly, and call up the Solver. The Solver should
recalucatue based on the new constraints.

Hopes this helps.

RichardG

"David" wrote in message ...
I am writing a simple program to use solver to asnwer a question. The user
interface will be on a spreadsheet, and I would like the user to adjust
certain parameters, then click a macro button which will call up solver and
"solve the problem". The problem is, I am trying to enable the user to
adjust the valueof parameter in solverok by changing a cell on the
spreadsheet, then clicking the button to get the answer. Unfortunately, that
"valueof" parameter does not appear to take a cell location. Can someone
suggest a simple workaround to make this work. Here is the macro code i am
using now.


SolverReset
SolverAdd cellref:="$I$4", relation:=1, formulatext:="$D$4/$D$2"
SolverAdd cellref:="$I$4:$I$8", relation:=3, formulatext:="0"
SolverAdd cellref:="$I$4", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$5", relation:=1, formulatext:="$D$5/$D$2"
SolverAdd cellref:="$I$5", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$6", relation:=1, formulatext:="$D$6/$D$2"
SolverAdd cellref:="$I$6", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$7", relation:=1, formulatext:="$D$7/$D$2"
SolverAdd cellref:="$I$7", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$8", relation:=1, formulatext:="$D$8/$D$2"
SolverAdd cellref:="$I$8", relation:=4, formulatext:="integer"

SolverAdd cellref:="$I$4", relation:=3, formulatext:="($D$4/$D$2)-4"
SolverOk SetCell:="$J$9", MaxMinVal:=3, valueof:=i, ByChange:="$I$4:$I$8"

SolverSolve Userfinish:=True
SolverFinish Keepfinal:=1

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Interesting Solver problem (Solver encounters an error) MrShorty Excel Discussion (Misc queries) 3 December 22nd 05 10:52 PM
Resetting Solver Manually to Fix Solver Bug Stratuser Excel Programming 0 September 13th 04 07:04 PM
VBA code to add a reference to solver Tbeek[_3_] Excel Programming 5 April 7th 04 04:46 PM
Solver code does not save results to sheet - What am I missing?! Simon Livings Excel Programming 0 January 16th 04 03:55 PM


All times are GMT +1. The time now is 11:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"