LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Calling up the Solver function in a VBA macro

Hmmm - Just tried it on XL2000 and it worked fine. You haven't got any event
macros that might be conflicting as it was a new workbook.

Do other macros work OK, eg just doing basic stuff. Is this peculiar to just
Solver?

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"Wayne Stewart" wrote in message
...
Thanks for the response Ken.

I just loaded up a new excel workbook and inserted your
ExampleSolv macro in a module within this new workbook. I
established the Solver reference as instructed since the
module is new (this was done already on my original macro).

When I run the macro nothing happens (just like my
original macro). The screen seems to blink for a
microsecond, as if something is being calculated in the
background. However, cell A2 doesn't change from 5 to 1
like it's supposed to.

This is a very basic macro test and solver doesn't
respond. Is the problem with Excel?

For you reference, I am running Windows 2000, Excel 2000
SP-3

Any other thoughts?

Thanks.
-Wayne

-----Original Message-----
Do you mean you still have to hit OK on the dialog box

for it to take the value?
Have you referenced the Solver addin from your project

(tools / References /
Check 'Solver')

Does your code look something like this:-

Sub ExampleSolv()
SolverOk SetCell:="$A$3", MaxMinVal:=3,

ValueOf:="10", ByChange:="$A$2"
SolverSolve (True)
End Sub

Note you need the parameter True set on the SolverSolve

bit if you want it to
accept the value within the code without a dialog box.

Does the above code work for you if you try that with say

10 in A1, 5 in A2 and
=A1*A2 in A3?

--
Regards
Ken....................... Microsoft MVP -

Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------

------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------

------------------



"Wayne Stewart" wrote in message
...
I am trying to automate the Solver routine (Under the
Tools pull-down menu) using a VBA macro. I have

succeeded
at setting the constraints and the various options using
the "SolverAdd" and "SolverOptions" commands. However,
the problem seems to be with the "SolverOK" command,

where
the "Set Target Cell", "MaxMinValue", and "By Changing
Cells" fields are set. Solver does not seem to register
these values when the "SolveOK" command is used. Also,
when I use the "SolverReset" command followed
by "SolverAdd", and "SolverOptions" commands, no
parameters are passed to solver either.

The only way I can get the "By Changing Cells" cells
actually changing on the excel worksheet is to first
invoke solver manually (outside the macro), get the
solution by clicking "solve", then deleting the fields

in
the solver dialog box, closing solver, and then running
the macro!

Is there a glitch with Excel? Is there a patch that can
be downloaded to fix this problem? I'm positive that my
syntax is correct (the help examples are very straight
forward).

I don't get any error messages when I run the macro. It
simply just doesn't present the solution on the

worksheet.

Hope someone can help me!



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.567 / Virus Database: 358 - Release Date:

24/01/2004


.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.567 / Virus Database: 358 - Release Date: 24/01/2004


 
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
Calling a function in my SQL-DB from VBA KSor Excel Discussion (Misc queries) 0 March 11th 09 02:08 PM
calling worksheet function from a macro Joe Farruggio Excel Worksheet Functions 3 November 20th 06 10:01 PM
Calling Solver from VBA Nick Excel Programming 0 September 16th 03 03:24 PM
Calling macro in add-in. Clark B Excel Programming 1 July 24th 03 11:05 PM
Calling the Solver via a subroutine James[_8_] Excel Programming 1 July 10th 03 01:08 AM


All times are GMT +1. The time now is 09:42 PM.

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

About Us

"It's about Microsoft Excel"