View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
jerome drean[_2_] jerome drean[_2_] is offline
external usenet poster
 
Posts: 9
Default solver add in / excel solver / vba

Hi Jon

Lets assume that you want to optimise a function f (x1,x2,x3...)

option 1
You can use a worksheet and in cell a1 write =f(b1,b2,b3)
where b1 will contain x1
b2 will contain x2
b3 will contain x3
then use the solver by "Tools-solver ..."
this is plain excel

option 2
do the same in vba by creating a worksheet / workbook and dumping the
relevant information in the relevant cell and call solver ok ... like
Sub solvermatchvol()
SolverOk SetCell:="$a$1", MaxMinVal:=2,
ValueOf:="0",ByChange:="$b$1:$b$3"
SolverSolve UserFinish:=True
end sub
this is plain vba interacting with excel

option 3
try to use the functionalities of the solver directly in vba without any
interaction with any cells (this would be similar to have an external dll and
link to it from vba)
since excel is so rich of functionalities (optimisation, graphics) i always
wondered why excel does not give the user the option to call the functions
from vba not using any excel object such as worksheet / range etc...

It was a general comment to see if other users are trying to use vba without
excel standard objects the reason being that excel is great for manipulating
small amount of data but slow with a lot of calculations and lots of data
therefore it is more efficient to control the calculation from vba totally.
This having been said it is alwasy possible to hide worksheet and dump in
them necessary results to perform the task but it is not very nice solution.

Alternatively it is possible to write code in C but it is more complicated
and slow to program since it is difficult to access all classes

Another example can be:
the user gives a few parameters to a sub and wants to see a graph that is
based on the genration of large amount of data from the few parameters -- it
would be nice to call the graphical tool of excel by passing the data from
vba in a 2*2 matrix
without dumping the data in excel (even more when the data is greater than
65k rows)