Select first field whilst autofilter is on

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
 
D

Dave Peterson

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
 

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