excel - How to select the first visible row after applying a filter -
i'm filtering table in excel want first line appears.
use range.specialcells method xlcelltypevisible parameter on filtered range. .rows(1).cells
should want.
sub first_row() dim rfirstfilteredrow range worksheets("sheet1") .cells(1, 1).currentregion 'do .autofilter stuff here .resize(.rows.count - 1, .columns.count).offset(1, 0) if cbool(application.subtotal(103, .cells)) set rfirstfilteredrow = _ .specialcells(xlcelltypevisible).rows(1).cells '~~> rfirstfilteredrow not copy of first visible row 'do rfirstfilteredrow end if end end end end sub
you have transcribe suit own implementation of autofilter method.
the native worksheet subtotal function used counts visible cells. easy non-destructive way of determining whether there cells reference after filter has been applied.
Comments
Post a Comment