![]() |
Macro to select the result of an autofilter action
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 |
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 |
All times are GMT +1. The time now is 07:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com