ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Solver within Macro (https://www.excelbanter.com/excel-programming/280609-using-solver-within-macro.html)

Avner Mediouni

Using Solver within Macro
 
Dear Excel Programers,
I would like to know if it is possible to use solver from within a macro,
but not with value kept in cells but with values kept in variables.
for examples, supose I have two variables:
X = 3 and Y = 2. and I want to solve the linear equation:
Y = a*X + b
I would like to pass the function a*X+b-Y to the Solver and solve for a and
b, without having to write the data to cells in a worksheet and read the
results from this worksheet.

Thanks for the help

Sincerely yours,

Avner Mediouni
R&D Physicist
email:



Dana DeLouis[_5_]

Using Solver within Macro
 
I may be wrong, but it looks like you have 1 equation with 2 unknowns.
There would be many solutions. For a particular solution, I believe you
need another equation or some type of constraint.
I believe the Solver tool only works with data from a spreadsheet. I don't
believe you can pass it an array of values. One of the first few steps of
Solver is to copy your "changing cells" on a worksheet so that you can later
click to restore the original values. The "Changing Cells" is a Range on
the worksheet.
With two equations in two unknowns, you should be able to Solve for a & b
directly.

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Avner Mediouni" wrote in message
...
Dear Excel Programers,
I would like to know if it is possible to use solver from within a macro,
but not with value kept in cells but with values kept in variables.
for examples, supose I have two variables:
X = 3 and Y = 2. and I want to solve the linear equation:
Y = a*X + b
I would like to pass the function a*X+b-Y to the Solver and solve for a

and
b, without having to write the data to cells in a worksheet and read the
results from this worksheet.

Thanks for the help

Sincerely yours,

Avner Mediouni
R&D Physicist
email:






All times are GMT +1. The time now is 11:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com