Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Cool how to use Solver in Excel VBA

Hi all,

I'm trying to use solver to minimize a cell for a least squares regression. The minimization cell is a weighted sum of squared residuals. Three variables exist that define the regression line. Another six cells define the bounds for the variables.

I get the following error:

Compile Error: Sub or Function not defined

Here is the code:

Sub WLS_VARIO()
'
Range("F14").Select

ActiveCell.FormulaR1C1 = "=RC[-2]/1.1"
ActiveCell.Offset(1, 0).FormulaR1C1 = "=RC[-2]/1.1"
ActiveCell.Offset(2, 0).FormulaR1C1 = "=RC[-2]/1.1"

ActiveCell.Offset(0, 1).FormulaR1C1 = "=RC[-3]*1.1"
ActiveCell.Offset(1, 1).FormulaR1C1 = "=RC[-3]*1.1"
ActiveCell.Offset(2, 1).FormulaR1C1 = "=RC[-3]*1.1"

Range("F14:G16").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
SolverReset
SolverOk SetCell:="$D$12", MaxMinVal:=2, ValueOf:=0, ByChange:="$D$14:$D$16", _
Engine:=3, EngineDesc:="Evolutionary"
SolverAdd CellRef:="$D$14", Relation:=1, FormulaText:="$G$14"
SolverAdd CellRef:="$D$15", Relation:=1, FormulaText:="$G$15"
SolverAdd CellRef:="$D$16", Relation:=1, FormulaText:="$G$16"
SolverAdd CellRef:="$D$14", Relation:=3, FormulaText:="$F$14"
SolverAdd CellRef:="$D$15", Relation:=3, FormulaText:="$F$15"
SolverAdd CellRef:="$D$16", Relation:=3, FormulaText:="$F$16"
SolverSolve

End Sub

Any help please?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default how to use Solver in Excel VBA

Sounds like you haven't set the "SOLVER" reference. There is a good article about how to do so he http://peltiertech.com/Excel/SolverVBA.html
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
solver add in / excel solver / vba jerome drean[_2_] Excel Programming 8 September 21st 07 09:28 AM
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


All times are GMT +1. The time now is 01:30 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"