As I assume with visible cells that you got hidden rows you could try this modification on the original code:
For i = 2 To Range("AJ" & Rows.Count).End(xlUp).Row
If Rows(i).Hidden = True Then
Else
SolverReset
SolverOk SetCell:="$AJ$" & i, MaxMinVal:=2, ValueOf:=5, ByChange:="$AJ$" & i, Engine:=1
SolverAdd CellRef:="$AJ$" & i, Relation:=1, FormulaText:="$AE$" & i
SolverAdd CellRef:="$AJ$" & i, Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$AP$" & i, Relation:=3, FormulaText:="5"
SolverSolve Userfinish:=True
End If
Next
Alf
Bookmarks