Top of AutoFiltered Range?

G

Guest

Here's a little "snip" of code:

Windows("GOTU_Earn_Bal_2001_02 .xls").Activate
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="HDQ"
Selection.SpecialCells(xlCellTypeVisible).Select
Set rngSelection = Range(Range("C2").End(xlUp), Range("C2").End(xlDown))

The first four lines do wxactly what I want them to. Obviously the fifth
line does not. What I want is to go to the top of the visible selection. This
is dealing with about 500 Rows out of 60,000, so for speed and efficiency, I
want to do a For Each intRow through only the visible Rows.

Is there a way to do this?
 
R

Ron de Bruin

If I understand you correct ?

Maybe this will help to select the first visible data cell

First cell of the selection is a header

Sub Test()
Dim rng As Range

With Selection
.AutoFilter Field:=1, Criteria1:="HDQ"
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count) _
.SpecialCells(xlCellTypeVisible).Cells(1)
rng.Select
On Error GoTo 0
End With
End With
End Sub
 
G

Guest

Slicker 'n a pig in poop! Thanks a gang.
--
Dave
Temping with Staffmark
in Rock Hill, SC


Ron de Bruin said:
If I understand you correct ?

Maybe this will help to select the first visible data cell

First cell of the selection is a header

Sub Test()
Dim rng As Range

With Selection
.AutoFilter Field:=1, Criteria1:="HDQ"
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count) _
.SpecialCells(xlCellTypeVisible).Cells(1)
rng.Select
On Error GoTo 0
End With
End With
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