ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Top of AutoFiltered Range? (https://www.excelbanter.com/excel-programming/392748-top-autofiltered-range.html)

Dave Birley

Top of AutoFiltered Range?
 
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?
--
Dave
Temping with Staffmark
in Rock Hill, SC

Ron de Bruin

Top of AutoFiltered Range?
 
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


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dave Birley" wrote in message ...
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?
--
Dave
Temping with Staffmark
in Rock Hill, SC


Dave Birley

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


"Ron de Bruin" wrote:

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


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dave Birley" wrote in message ...
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?
--
Dave
Temping with Staffmark
in Rock Hill, SC




All times are GMT +1. The time now is 01:22 AM.

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