+ Reply to Thread
Results 1 to 2 of 2

Input two cell references into Excel Solver

  1. #1
    Registered User
    Join Date
    03-09-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Input two cell references into Excel Solver

    Hi,

    I am trying to enter two variable cell references via a macro into the excel solver to allow me to solve multiple cells. I can do this if I have a single variable cell, but not for multiple cells. Here is my code, any ideas?
    I keep getting the "Expected: end of statement error when I compile.


    Dim i As Integer

    Dim x As String

    For i = 12 To 26


    SolverReset
    x = "$C$" & i "," "$L$" & i
    SolverOk SetCell:="$BM$" & i, MaxMinVal:=2, ValueOf:="0", ByChange:=x
    SolverAdd CellRef:="$P$" & i, Relation:=3, FormulaText:="$D$5"
    SolverAdd CellRef:="$R$" & i, Relation:=3, FormulaText:="$Q$" & i
    SolverAdd CellRef:="$AF$" & i, Relation:=3, FormulaText:="$D$6"
    SolverAdd CellRef:="$AO$" & i, Relation:=3, FormulaText:="$AK$" & i
    SolverAdd CellRef:="$AR$" & i, Relation:=3, FormulaText:="$AL$" & i
    SolverOk SetCell:="$BM$" & i, MaxMinVal:=2, ValueOf:="0", ByChange:=x
    SolverSolve
    SolverSolve UserFinish:=True
    SolverFinish KeepFinal:=1
    SendKeys "{ENTER}"

    Next i

    The red line is the one causing the problems. I want to vary the row aka the i value.

    Cheers

    Guern

  2. #2
    Registered User
    Join Date
    03-09-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Input two cell references into Excel Solver

    Sorry in advance for the poor coding practice.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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