VBA Excel - Select first filtered cell

User avatar
ErikJan
BronzeLounger
Posts: 1243
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

VBA Excel - Select first filtered cell

Post by ErikJan »

I have a table with a header. I apply a filter in VBA. I move the upper-left cell to the top of my screen (Application.goto Range("A1"), True).
Now I want to select the first visible cell in column A (that might not be A1 of course). How do I do that?

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VBA Excel - Select first filtered cell

Post by HansV »

For example

Code: Select all

    Application.GoTo Range("A2:A1048576").SpecialCells(xlCellTypeVisible).Cells(1)
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: VBA Excel - Select first filtered cell

Post by Rudi »

Alternatively, if it is an Excel Table (LIstObject) then:

Code: Select all

    ActiveSheet.ListObjects(1).DataBodyRange.SpecialCells(xlCellTypeVisible).Cells(1).Select
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.