Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using Solver Thru VBA

Hi there
I was using VBA to automate repeated use of Solver. My requirements are that
solver is called twice for two models in different worksheets and then, the
process is repeated till a satisfactory answer reached. I wrote following
lines to do part of my problem:

SolverReset
SolverOk SetCell:=Worksheets(1).Range($F$6:$F$10), MaxMinVal:=2,
ByChange:=Worksheets(1).Range("Y")
SolverAdd CellRef:=Worksheets(1).Range(Z), Relation:=3, FormulaText:="U"
SolverOPtions AssumeLinear:=True, AssumeNonneg:=True
SolverSolve(UserFinish:=True)
SolverFinish KeepFinal:=1

The problem I am encountering is that the Solver changes the cell
"$F$6:$F$10" only on the worksheet which is active despite explicitly
defining the changeable cells on worksheet1. If worksheet 3 is active, it
will change its cells "$F$6:$F$10". Since, I am running two solvers on
seperate worksheets, both solvers change cells on the worksheet which is
active.

Can any one help, please Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Using Solver Thru VBA

Both the Target cell and the Adjustabl;e cell have to be on the active
worksheet.
--
Gary''s Student - gsnu200908
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Using Solver Thru VBA

SolverOk SetCell:=Worksheets(1).Range($F$6:$F$10)

Hello. Your reference for Target doesn't meet the two requirements.
ie Single Cell, and Active Sheet

From Help:
SetCell Optional Variant. Refers to a single cell on the active worksheet.


As a side note...

SolverSolve(UserFinish:=True)
SolverFinish KeepFinal:=1


I noticed your use of () in the SolverSolve line.
"Usually" one tests Solver's results via that method:
ie
Results = SolverSolve(True) 'Hopefully, 0,1, or 2

= = = = =
HTH
Dana DeLouis



On 10/25/09 11:49 AM, Mallick wrote:
Hi there
I was using VBA to automate repeated use of Solver. My requirements are that
solver is called twice for two models in different worksheets and then, the
process is repeated till a satisfactory answer reached. I wrote following
lines to do part of my problem:

SolverReset
SolverOk SetCell:=Worksheets(1).Range($F$6:$F$10), MaxMinVal:=2,
ByChange:=Worksheets(1).Range("Y")
SolverAdd CellRef:=Worksheets(1).Range(Z), Relation:=3, FormulaText:="U"
SolverOPtions AssumeLinear:=True, AssumeNonneg:=True
SolverSolve(UserFinish:=True)
SolverFinish KeepFinal:=1

The problem I am encountering is that the Solver changes the cell
"$F$6:$F$10" only on the worksheet which is active despite explicitly
defining the changeable cells on worksheet1. If worksheet 3 is active, it
will change its cells "$F$6:$F$10". Since, I am running two solvers on
seperate worksheets, both solvers change cells on the worksheet which is
active.

Can any one help, please Thanks

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
Solver VBA - Defining Solver Options Kyle Excel Programming 5 March 21st 08 10:41 AM
referencing Solver.xlam vs. Solver.xla - 2007 vs. 2003 Duke Carey Excel Programming 3 November 20th 07 03:48 PM
How to replace Excel solver with some free solver codes in Excel V ct2147 Excel Programming 2 November 8th 06 07:06 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


All times are GMT +1. The time now is 04:20 PM.

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"