Select next visible row (like pressing {down})

5.7k Views Asked by At

I've done a ton of reseach and I've found a code that worked partially for me.
All I want is a code that simply go to the next cell below but the rows are filtered.
The problem with this code is that it goes to the very first row (header) and then it offsets to the next below line.

With ActiveSheet.AutoFilter.Range
    Range("E" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Select
End With

I hope the code does this, but the rows are not consecutives:

3

There are 3 best solutions below

0
Afonso Medeiros On BEST ANSWER

I spent all night google-ing and reading docs about Do While with the idea of using ActiveCell.EntireRow.Hidden = True and there's the final idea:

ActiveCell.Offset(1, 4).Activate 'because I want to activate column "E"
Do While ActiveCell.EntireRow.Hidden = True
  ActiveCell.Offset(1, 0).Activate
Loop
1
WeAreOne On

I googled it for you!

Sub GoToNextVisibleCellBelow()

    Do
        ActiveCell.Offset(1, 0).Select
    Loop While ActiveCell.EntireRow.Hidden = True

End Sub
0
Luis Vidal On

Don't loop! There's a better way to do this!

The SendKeys keyword will instruct the application to mimic a key press or combination of key presses. In your case you'll want to use:

SendKeys "{Down}"

This way you can "press down key" and move down one visible cell.

See documentation for more info on how to use:

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/sendkeys-statement