Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Minimization VBA Code
Thanks Thanks: 0 Likes Likes: 0

  1. #11
    New Member
    Join Date
    Aug 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Minimization VBA Code

    Hi Fazza, I did that one already

  2. #12
    MrExcel MVP
    Join Date
    May 2006
    Location
    Excel 2003, Australia
    Posts
    9,155
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Minimization VBA Code

    great.

    which lines causes the error?
    To receive a better answer, put more work into asking the question.


  3. #13
    New Member
    Join Date
    Aug 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Minimization VBA Code

    Hi Fazza, the first line of the code. Its says that sub or function not defined

  4. #14
    MrExcel MVP
    Join Date
    May 2006
    Location
    Excel 2003, Australia
    Posts
    9,155
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Minimization VBA Code

    I think all I can suggest is you re-visit https://docs.microsoft.com/en-us/off...-vba-functions
    To receive a better answer, put more work into asking the question.


  5. #15
    New Member
    Join Date
    Aug 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Minimization VBA Code

    Ok but is the code correct?
    What should i edit it to fit it as per the vba code?
    Last edited by matthew_ong12; Aug 30th, 2018 at 11:43 PM. Reason: Additional comment

  6. #16
    New Member
    Join Date
    Aug 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Minimization VBA Code

    Hi Fazza, I already did the add on on excel but i still encounter the same problem.
    Here's the code that was generated when i did the record macro.

    Sub FuelOptimization()
    '
    ' FuelOptimization Macro
    '


    '
    SolverOk SetCell:="$B$379", MaxMinVal:=2, ValueOf:=0, ByChange:="$C$382:$C$384" _
    , Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverDelete CellRef:="$B$380", Relation:=2, FormulaText:="0"
    SolverAdd CellRef:="$B$380", Relation:=2, FormulaText:="0"
    SolverOk SetCell:="$B$379", MaxMinVal:=2, ValueOf:=0, ByChange:="$C$382:$C$384" _
    , Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverDelete CellRef:="$C$382", Relation:=1, FormulaText:="$F$382"
    SolverAdd CellRef:="$C$382", Relation:=1, FormulaText:="$F$382"
    SolverOk SetCell:="$B$379", MaxMinVal:=2, ValueOf:=0, ByChange:="$C$382:$C$384" _
    , Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverDelete CellRef:="$C$383", Relation:=1, FormulaText:="$F$383"
    SolverAdd CellRef:="$C$383", Relation:=1, FormulaText:="$F$383"
    SolverOk SetCell:="$B$379", MaxMinVal:=2, ValueOf:=0, ByChange:="$C$382:$C$384" _
    , Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverDelete CellRef:="$C$384", Relation:=1, FormulaText:="$F$384"
    SolverAdd CellRef:="$C$384", Relation:=1, FormulaText:="$F$384"
    SolverOk SetCell:="$B$379", MaxMinVal:=2, ValueOf:=0, ByChange:="$C$382:$C$384" _
    , Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverOk SetCell:="$B$379", MaxMinVal:=2, ValueOf:=0, ByChange:="$C$382:$C$384" _
    , Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverSolve
    End Sub

    When i try to run the macro, it displays an error of "sub or function not defined". I'm not quite sure where the error lies since i just use the record macro. Kindly enlighten me

  7. #17
    New Member
    Join Date
    Aug 2018
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Minimization VBA Code

    Hi Mr Excel, would like to ask how to change a single reference cell to a range for a goal seek scenario. Here's the code.

    Sheets("Fuel Plan").Select
    Range("h6").Select
    Range("h6").GoalSeek Goal:=Range("i6"), ChangingCell:=Range("E2")
    Range("E2").Select

    In this example, it only changes one particular value of the cell which is "E2" now if I want to expand it and change it to say "e2:e3" how should I edit the code?

    Hoping to hear from you

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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