Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 11-06-2005, 02:41 AM   #1
Solid State Member
Join Date: Jun 2005
Posts: 13
Default VBA and Solver Help?


I am trying to write some code in visual basic using Solver. I recorded a macro in Excel (Office XP) to create the code. However, when I run my macro, Excel says that the functions are undefined. This is the section of code that is causing me trouble:

SolverOk SetCell:="$M$2", MaxMinVal:=1, ValueOf:="0", ByChange:= _
SolverAdd CellRef:="$G$2", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$7", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$10", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$13", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$15", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$G$17", Relation:=2, FormulaText:="1"
SolverAdd CellRef:="$M$2", Relation:=2, FormulaText:="$B$20"
SolverOk SetCell:="$M$2", MaxMinVal:=1, ValueOf:="0", ByChange:= _

Any help at all would be greatly appreciated.


danby is offline   Reply With Quote
Old 12-08-2005, 05:40 PM   #2
Beta Member
Join Date: Dec 2005
Posts: 1
Default Re: VBA and Solver Help?

Is it just you using this workbook? Then you just need to set a reference. In the VB Editor, select the project containing this code in the Project Explorer window. On the Tools menu, select References, then scroll down the list until you find Solver, and check the box in front of it.

Now the workbook knows where to look for those functions.

- Jon
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
JonPeltier is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

All times are GMT -5. The time now is 04:56 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0