Thank you to Simoco for identifying the omission of '.Address', but I still could not get the above to work, when defining the MaxMinVal as a cell (instead of just '1' or '2')
So I used a nested IF statement as follows - this works but there may be a more elegant way and if anyone can give me tips on this it would be appreciated:
Sub Optimise()
'
Dim OptiRange As Range
' Activate the sheet required and reset solver settings
Sheets("Dashboard").Activate
SolverReset
' Add-in some bad error handling ;-)
On Error GoTo endofmacro
'Ask user for what cells to optimise
Set OptiRange = Application.InputBox("Use the mouse to select cells to optimise (Hold Ctrl to select multiple films individually)", Type:=8)
'Check if this is a maximise or minimise problem
If Range("$Z$15").Value = 1 Then
'
'Set solver parameters and solve using GRG Nonlinear
SolverOk SetCell:="$Z$13", MaxMinVal:=1, ValueOf:=0, ByChange:=OptiRange.Address, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
Else
'
'Set solver parameters and solve using GRG Nonlinear
SolverOk SetCell:="$Z$13", MaxMinVal:=2, ValueOf:=0, ByChange:=OptiRange.Address, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
End If
endofmacro:
End Sub