Consulting

Results 1 to 5 of 5

Thread: Sleeper: VBA function "sub not defined"

  1. #1

    Sleeper: VBA function "sub not defined"

    Hello all,

    I can't get my macro to work. The error i get is 'Sub not defined' this is my code

    Public Sub Solver()
    ' Solver Macro
    ' Keyboard Shortcut: Ctrl+s
        SolverOk SetCell:="$AF$3", MaxMinVal:=3, ValueOf:=8.73, ByChange:="$AD$3", _
            Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverOk SetCell:="$AF$3", MaxMinVal:=3, ValueOf:=8.73, ByChange:="$AD$3", _
            Engine:=1, EngineDesc:="GRG Nonlinear"
        SolverSolve
    End Sub
    Does anyone know how to define this sub?
    Thanks in advance!
    Last edited by Aussiebear; 05-20-2022 at 03:05 AM. Reason: Added code tags to supplied code

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    You could try to rename your Sub, just in case "Solver" is a reserved word in Excel. what does "Solversolve" mean?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    SolverSolve means that the solver will run to get a value

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,192
    Location
    Might be worth reading the note section of the below:
    https://docs.microsoft.com/en-us/off...verok-function
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    Quote Originally Posted by dennisvveen View Post
    SolverSolve means that the solver will run to get a value
    . I understand that, but in using Solversolve without using the two missing Optional variants doesn't help us to understand where you are trying to get to.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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