PDA

View Full Version : Sleeper: VBA function "sub not defined"



dennisvveen
05-20-2022, 02:55 AM
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!

Aussiebear
05-20-2022, 03:08 AM
You could try to rename your Sub, just in case "Solver" is a reserved word in Excel. what does "Solversolve" mean?

dennisvveen
05-20-2022, 03:29 AM
SolverSolve means that the solver will run to get a value

georgiboy
05-20-2022, 03:32 AM
Might be worth reading the note section of the below:
https://docs.microsoft.com/en-us/office/vba/excel/concepts/functions/solverok-function

Aussiebear
05-20-2022, 01:00 PM
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.