#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default solver

i recorded a macro while using the solver function, which worked, but when i
tried to re-use the code that it had recorded, it said "sub or function not
defined" and highlighted "SolverOk"

sub test()
SolverOk SetCell:="$G$1", MaxMinVal:=3, ValueOf:=".0124", ByChange:="$G$2"
SolverSolve
end sub

any thoughts? thanks, mike allen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default solver

Hi Mike,

You need to set a reference to the Solver add-in for this to work.
First, make sure Solver is actually open by choosing Tools/Solver from the
Excel menu and then just closing the Solver dialog (the Solver add-in won't
necessarily be open when you first start Excel because it's a demand-loaded
add-in).

Next activate the workbook with your code in it and choose Alt+F11 to
open the Visual Basic Editor. From the VBE menu choose Tools/References. Put
a check mark beside the reference called SOLVER. Save your workbook. The
code should run now.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"mike allen" wrote in message
...
i recorded a macro while using the solver function, which worked, but when

i
tried to re-use the code that it had recorded, it said "sub or function

not
defined" and highlighted "SolverOk"

sub test()
SolverOk SetCell:="$G$1", MaxMinVal:=3, ValueOf:=".0124", ByChange:="$G$2"
SolverSolve
end sub

any thoughts? thanks, mike allen




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
Using Solver Randy Excel Discussion (Misc queries) 3 October 1st 09 03:32 PM
Using solver Leog Excel Worksheet Functions 2 August 17th 09 06:47 PM
Solver Alonso[_2_] Excel Worksheet Functions 4 November 12th 08 10:41 PM
need help in SOLVER !! Ah NeL Excel Discussion (Misc queries) 1 December 26th 06 04:24 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 09:45 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"