Help required to select a cell in a filtered list

J

Jim

Windows XP and Excel 2003
I have filtered some rows of data and would like to move the active cell
sequentially down the list.
Equivalent to using the cursor down key ... Is this possible with vba

Regards & TIA
 
D

Dave Peterson

I'd just look for a row that's visible:

Option Explicit
Sub testme()

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim CurRow As Long

CurRow = ActiveCell.Row
With ActiveSheet.AutoFilter.Range
FirstRow = .Row
LastRow = .Rows(.Rows.Count).Row
End With

If CurRow >= LastRow _
Or CurRow < FirstRow Then
MsgBox "not in the autofilter range--or out of room!"
Exit Sub
End If

Do
If ActiveCell.Row = LastRow Then
Exit Do 'at the bottom of the range
End If

ActiveCell.Offset(1, 0).Select

If ActiveCell.Row > LastRow Then
MsgBox "Out of the autofilter range!"
Exit Do
End If

If ActiveCell.EntireRow.Hidden = True Then
'keep looking
Else
Exit Do
End If
Loop

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