Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Iterate through the autofiltered rows

Hi,

I want to iterate through all rows which are currently visible with an
activated autofilter.
I tried the Range Autofiler.Range but that gave me all rows in (also
the ones which are not visible!)
then i tried: Set oRng = AutoFilter.Range.Cells.SpecialCells
(xlCellTypeVisible) but that gave me only 1 row (I think it will be
the title line).

What I want to do ist

do while ' there are more rows available through the autofilter result
' work on the rows which are visible through the autofilter
loop

I am not interested in the setting filter criterias through my macro!

Any help on this one greatly appreciated

Best regards
Hannes
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Iterate through the autofiltered rows

Hi,

This works on a filtered range in column A and loops through the visible rows

Sub Sonic()
Dim MyRange as Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
If Not c.EntireRow.Hidden Then
'your code goes here
End If
Next
End Sub

Mike

"hheckner" wrote:

Hi,

I want to iterate through all rows which are currently visible with an
activated autofilter.
I tried the Range Autofiler.Range but that gave me all rows in (also
the ones which are not visible!)
then i tried: Set oRng = AutoFilter.Range.Cells.SpecialCells
(xlCellTypeVisible) but that gave me only 1 row (I think it will be
the title line).

What I want to do ist

do while ' there are more rows available through the autofilter result
' work on the rows which are visible through the autofilter
loop

I am not interested in the setting filter criterias through my macro!

Any help on this one greatly appreciated

Best regards
Hannes

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Iterate through the autofiltered rows

Dim VisRng as range
Dim myCell as range

With Worksheets("somesheetnamehere")
With .AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1 Then
'nothing visible
Set VisRng = Nothing
Else
'resize to avoid the header
'and come down one row
'single column of visible cells
Set VisRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
End If
End With
End With

If VisRng Is Nothing Then
MsgBox "No non-blanks in AA column A"
Else
for each mycell in visrng.cells
msgbox mycell.address(0,0)
next mycell
End If

hheckner wrote:

Hi,

I want to iterate through all rows which are currently visible with an
activated autofilter.
I tried the Range Autofiler.Range but that gave me all rows in (also
the ones which are not visible!)
then i tried: Set oRng = AutoFilter.Range.Cells.SpecialCells
(xlCellTypeVisible) but that gave me only 1 row (I think it will be
the title line).

What I want to do ist

do while ' there are more rows available through the autofilter result
' work on the rows which are visible through the autofilter
loop

I am not interested in the setting filter criterias through my macro!

Any help on this one greatly appreciated

Best regards
Hannes


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
iterate my rows rodchar Excel Programming 2 November 7th 08 07:27 PM
Iterate rows of spreadsheet(s}\Get values gh Excel Programming 1 May 8th 08 03:18 PM
Iterate rows, add like values - an easier way? Ed from AZ Excel Programming 1 April 3rd 08 06:09 PM
Deleting AutoFiltered Rows Nirmal Singh Excel Programming 11 February 7th 05 06:41 PM


All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"