🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.apps
Article #1270

Excel Macro+Solve Question

#1270
From: ra_novy
Date: Tue, 11 Aug 1992 21:25
47 lines
1942 bytes
In Excel 3.0a, I've been trying to write a macro that will call the Solver for
each row in a table of data:

   |  A   |   B   |   C
--------------------------
1  |  k   |   x   | f(k,x)
2  |  3   |   1   |   6
3  |  4   |   3   |   7
4  |  8   |   5   |   4
etc.

In Column A is k, a fixed parameter.
In Column B is x, a variable.
In Column C is a function of k and x that is to be zeroed by varying x.

So I'd like to have a macro that finds the root of f(k,x) at each value of k.

My problem involves referencing the value of x in the row that is being
processed.  The macro I have is

Record1 (a)
=RUN('SOLVER Add-in'!Auto_Open)
=FOR.CELL("TargetCell",,TRUE)     [loop through selected cells, i.e. col C]
=SOLVER.RESET()
=SOLVER.OK(TargetCell,3,0,!$B$2)  [make the target cell zero by varying B2]
=SOLVER.SOLVE()                   [execute solver]
=NEXT()                           [go to next selected cell]
=RETURN()

So as it is above, the macro always varies B2 to try to zero each of the values
in column C.  How do I get the solver to vary B3 to zero C3, to vary B4 to zero
C4, etc?

I've studied the darn manuals most of the afternoon, and I don't see how to
specify a cell on the ACTIVE sheet RELATIVE to another cell on the same sheet.

If there are several ways to do this, I'd like to be able to use the names of
the variables in the active sheet when writing the macro.  Names would be
better than row-column references.

Any suggestions would be appreciated.

Bob Novy
ra_novy@dal.mobil.com
Dallas, TX

Vacuous Justification #1: It's the '90s.
Technical Details
Message-ID: <9208112125.AA01959@mobil.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!ucbvax!DAL.MOBIL.COM!ra_novy

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!ucbvax!DAL.MOBIL.COM!ra_novy
From: ra_novy@DAL.MOBIL.COM
Newsgroups: comp.sys.mac.apps
Subject: Excel Macro+Solve Question
Message-ID: <9208112125.AA01959@mobil.com>
Date: 11 Aug 92 21:25:50 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 47