Counting Rows

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.
 
D

Dave Peterson

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.
 

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