View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default How do I choose the rows that are filtered ?

hi cupertino,

Sub Filtered_Data1()
'this example lists the data and addresses of the first (1) column of the filter

Dim S As Variant
Dim plg As Range, rng As Range, c As Range
Dim i As Integer, FirstAdd As String, LastAdd As String
Set plg = ActiveSheet.Range("_filterdatabase").SpecialCells( xlCellTypeVisible)

S = Split(plg.Address, ",")

For i = 0 To UBound(S)
For Each rng In Range(S(i)).Columns(1) 'adapt the "th" column
For Each c In Range(rng.Address)
If c.Address < ActiveSheet.Range("_filterdatabase")(1).Address Then 'adapt the "th" column
FirstAdd = c.Address
GoTo fin
End If
Next
Next
Next

fin:
LastAdd = Range(S(UBound(S))).Columns(1).Address
Range(FirstAdd & ":" & LastAdd).Select
End Sub


--
isabelle



Le 2012-02-15 19:08, cupertino a écrit :
Here is part of my macro

'' Formatting Alan with color
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.DisplayGridlines = False
Selection.AutoFilter Field:=1, Criteria1:="Alan"
Selection.AutoFilter Field:=3, Criteria1:="=Alan"

''''''''''' why is the next line A2 ?
Range("A2").Select

''''''''''' Above line could be A20, how do
How do I choose the rows that are filtered