Selection after filtering

  • Thread starter Thread starter Pedro
  • Start date Start date
P

Pedro

Hi,

I have a database that filtered
Now I want to select the next row after the 4th. Given that I have filter
the next row is the 777
What code should I write in order to select the row that is show by the
filter has the next to the 4th , taking into account that this can be change
if the filter change

Regards
PM
 
set rng = Activesheet.autofilter.Range.Columns(1)
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
set rng = rng.specialcells(xlVisible)
set rng1 = nothing
i = 0
for each cell in rng
i = i + 1
if i = 5 then
set rng1 = cell
exit sub
end if
Next
rng1.Select
 
Sub SelectFirstVisible()
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range.Columns(1)
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
On Error Resume Next
Set rng = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng Is Nothing Then
rng(1).Select
Else
MsgBox "No rows visible"
End If
End Sub
 
Back
Top