I have coded for a solver problem in macros. But the problem is the range in B column is auto filtered and the other rows are hidden. So as per inputs, only the rows in B column that satisfy the input are shown. It can start at any row. How do I include the code to use only visible cells in the column B for calculation? Pls help.

Dim Counter As Integer

Dim lastrow As String

Counter = 0

For Each Testname In Range("B3:B10000")

If IsEmpty(Testname) = False Then

Counter = Counter + 1

Else

Counter = Counter + 0

End If

Next Testname

SolverOk SetCell:="$T$1", MaxMinVal:=2, ValueOf:=0, ByChange:="$L$3:$L$counter", _

Engine:=1, EngineDesc:="GRG Nonlinear"

SolverOk SetCell:="$T$1", MaxMinVal:=2, ValueOf:=0, ByChange:="$L$3:$L$counter", _

Engine:=1, EngineDesc:="GRG Nonlinear"

SolverSolve

End Sub