Select first field whilst autofilter is on

  • Thread starter Thread starter bony_tony
  • Start date Start date
B

bony_tony

Hi, I'm having trouble getting my macro to go to the first row which
is visible, whilst the autofilter is on.
I can get to the last row by going to the bottom of the sheet, then
using XlEndUp, but I can't use it for the top row. If I use offset, it
will select one of the hidden cells...

Any help would be appreciated.

Thanks
 
Option Explicit
sub testme()
dim VRng as range
with activesheet.autofilter.range
if .columns(1).cells.specialcells(xlcelltypevisible).count = 1 then
msgbox "no visible cells
exit sub
end if
set Vrng = .columns(1).resize(.rows.count-1,1) _
.offset(1,0).cells.specialcells(xlcelltypevisible)
end with
vrng.cells(1).select
end sub
 
Back
Top