ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros with AutoFiltering (https://www.excelbanter.com/excel-programming/295310-macros-autofiltering.html)

[email protected]

Macros with AutoFiltering
 
If I have Autofiltering turned on, how can I tell from within a macro which
lines are selected?

for i = 1 to nRows
if row i is displayed then ....
next i



K Dales

Macros with AutoFiltering
 
Check the row height - filtering just sets the height to
zero to hide the row.

For i = 1 to nRows
If Sheets(MySheet).Rows(i).RowHeight 0 Then...
Next i

-----Original Message-----
If I have Autofiltering turned on, how can I tell from

within a macro which
lines are selected?

for i = 1 to nRows
if row i is displayed then ....
next i


.


[email protected]

Macros with AutoFiltering
 
Thanks for the reply. It answered the question and I got my code written.
However, I think I could have asked the question in a better way and
learned more. If I have autofiltering turned on, how can I write code to
acccomplish:

For each displayed row
Do something
Next displayed row

Thanks again.

On Fri, 16 Apr 2004 09:31:31 -0700, "K Dales"
wrote:

Check the row height - filtering just sets the height to
zero to hide the row.

For i = 1 to nRows
If Sheets(MySheet).Rows(i).RowHeight 0 Then...
Next i

-----Original Message-----
If I have Autofiltering turned on, how can I tell from

within a macro which
lines are selected?

for i = 1 to nRows
if row i is displayed then ....
next i


.



Ed[_9_]

Macros with AutoFiltering
 
This code increments down the visible cells in an AutoFiltered list. Wish I
could take credit, but I'm nowhere near that smart! Tom Ogilvy gave it to
me.

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub

Ed
wrote in message
...
Thanks for the reply. It answered the question and I got my code written.
However, I think I could have asked the question in a better way and
learned more. If I have autofiltering turned on, how can I write code to
acccomplish:

For each displayed row
Do something
Next displayed row

Thanks again.

On Fri, 16 Apr 2004 09:31:31 -0700, "K Dales"
wrote:

Check the row height - filtering just sets the height to
zero to hide the row.

For i = 1 to nRows
If Sheets(MySheet).Rows(i).RowHeight 0 Then...
Next i

-----Original Message-----
If I have Autofiltering turned on, how can I tell from

within a macro which
lines are selected?

for i = 1 to nRows
if row i is displayed then ....
next i


.






All times are GMT +1. The time now is 08:38 PM.

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