Selection after filtering

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
 
T

Tom Ogilvy

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top