ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select first field whilst autofilter is on (https://www.excelbanter.com/excel-programming/388715-select-first-field-whilst-autofilter.html)

bony_tony

Select first field whilst autofilter is on
 
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


Dave Peterson

Select first field whilst autofilter is on
 
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

bony_tony wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com