+ Reply to Thread
Results 1 to 2 of 2

Excel Solver with Macro doesn't work

  1. #1
    Jukka
    Guest

    Excel Solver with Macro doesn't work

    I have used a solver in Microsoft Excell to find a solution in a
    spreadsheet and the solver works and I can get a solution. I have
    several similar cases and I have tried to automate this process and I
    made a macro to do this.
    Here is the Macro:

    Sub optimointi()
    SolverReset
    SolverAdd CellRef:="$BJ$41:$BJ$52", Relation:=1,
    FormulaText:="$BG$7"
    SolverOk SetCell:="$BH$43", MaxMinVal:=2, ByChange:= _
    "$BJ$7,$BP$26:$BP$42"
    SolverSolve UserFinish:=True
    SolverFinish KeepFinal:=1
    End Sub

    This macro works alone fine everytime I start it from excell but if I
    add anything to a macro before SolverReset statement or if I call it
    from another macro it simply doesn't work. I doesn't give any error
    message. Strange for me.

    Does anybody have any idea what might be reason for this?

    Jukka

  2. #2
    Chad
    Guest

    RE: Excel Solver with Macro doesn't work

    I have had a somewhat similar problem. Try this:
    SOLVER.Auto_open
    before the solver reset statement.

    "Jukka" wrote:

    > I have used a solver in Microsoft Excell to find a solution in a
    > spreadsheet and the solver works and I can get a solution. I have
    > several similar cases and I have tried to automate this process and I
    > made a macro to do this.
    > Here is the Macro:
    >
    > Sub optimointi()
    > SolverReset
    > SolverAdd CellRef:="$BJ$41:$BJ$52", Relation:=1,
    > FormulaText:="$BG$7"
    > SolverOk SetCell:="$BH$43", MaxMinVal:=2, ByChange:= _
    > "$BJ$7,$BP$26:$BP$42"
    > SolverSolve UserFinish:=True
    > SolverFinish KeepFinal:=1
    > End Sub
    >
    > This macro works alone fine everytime I start it from excell but if I
    > add anything to a macro before SolverReset statement or if I call it
    > from another macro it simply doesn't work. I doesn't give any error
    > message. Strange for me.
    >
    > Does anybody have any idea what might be reason for this?
    >
    > Jukka
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1