View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Macro to select the result of an autofilter action

Sub selection()
Dim rng As Range

Rows("2:10").Delete Shift:=xlUp
Range("A1").AutoFilter
Set rng = Selection
rng.AutoFilter Field:=14, Criteria1:="=NAME", Operator:=xlAnd
Set rng = rng.SpecialCells(xlCellTypeVisible)
'you can now work with the rng object

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
oups.com...
I'm doing this in a macro:


Sub selection()
'

' Macro recorded 22/12/2005 by Me
'
Rows("2:10").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Selection.AutoFilter
ActiveWindow.SmallScroll ToRight:=2
Selection.AutoFilter Field:=14, Criteria1:="=NAME", Operator:=xlAnd
'Select the result here

End Sub

After the AutoFilter action, I need to select only the resulting rows
and columns (with datas)
and save them in a .csv file, knowing that the result will vary from
one day to another

I have tried several things, but the problem is that all the rows and
columns (even those not displayed) are always selected and saved. I
want only to have the ones given by the autofilter.
Who can help me?

Geo