I don 't know how to NEXT when I have multiple "for" statements.
Since you have 3 "For" statement you need 3 "Next" and the way it will work is that the last "For" will be "solved" first.
So first p = 10, i = 11 and d = 2 and with this setup solver will do the first run, the second run will use the same p and i value but d will now be 3. For the 3 run d = 4 and p and i are still 10 and 11 and so forth until d = 8.
The next run after d = 8 the i value will change to 12 and the d value will start at 2 again loop through the d values 2 to 8, then change the i value to 13 and loop through all d values and so fort.
When the i = 17 the next loop change the p value to 11.
Sub Pricing()
'
' Pricing Macro
'
'
Dim p As Integer
Dim i As Integer
Dim d As Integer
For p = 10 To 16 'for price table increment reference
For i = 11 To 17 'for irr table increment reference
For d = 2 To 8 'for dm table increment reference
SolverReset
SolverOk SetCell:=Cells(24,i).Address, MaxMinVal:=3, ValueOf:=0.2, ByChange:=Cells(3,p).Address, Engine:=1
SolverAdd CellRef:=Cells(24,d).Address, Relation:=3, FormulaText:="0.24"
SolverSolve UserFinish:=True
Next ' next d
Next ' next i
Next ' next p
End Sub
Solver will not understand SetCell:="(24,i)" so I've changed your code a bit. When writing code it should be wrapped click on the "#" icon and write your code between two [CODE] symbols you get.
In you code you wrote Engine:=1, EngineDesc:="GRG Nonlinear" this is not wrong but you only need to specify either "Engine:=1" or EngineDesc:="GRG Nonlinear"
Alf
Bookmarks