Counting Rows

  • Thread starter Thread starter shimeel
  • Start date Start date
S

shimeel

Also, i need to select the first row after the header.. so ,

10 <- header
(series of filtered out rows)
First visible row after header

how could i select the first visible row after header ?


Shimeel.
 
One way:

Option Explicit
Sub testme()

Dim myRng As Range

With ActiveSheet.AutoFilter.Range
Set myRng = Nothing
On Error Resume Next
Set myRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "no visible rows in filtered range"
Else
myRng.Cells(1).Select
End If
End With

End Sub

The .resize() stuff says to subtract one row from the autofilter range (the
header) and to only consider the first column of that filtered range.

The .offset() stuff says to come down one row (where the data starts).

The .specialcells() stuff says to only look at the visible cells.

The .cells(1) says to look at the first cell in that range.
 
Back
Top