ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autofilter, command to select filtered range? (https://www.excelbanter.com/excel-programming/375165-autofilter-command-select-filtered-range.html)

matthias

autofilter, command to select filtered range?
 
Hello guys,

I apply a autofilter in my macro. It filters a range in column a with
criteria ="Y". Then I want to copy the lines in column a who fulfill
this criteria to a new sheet (also in column a)


what is the command for this?

thankx


Mike Fogleman

autofilter, command to select filtered range?
 
I got this from Tom:

Sub CopyFilter()
'by Tom Ogilvy
Dim rng As Range
Dim rng2 As Range

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No data to copy"
Else
Worksheets("Sheet2").Cells.Clear
Set rng = ActiveSheet.AutoFilter.Range
rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
Destination:=Worksheets("Sheet2").Range("A1")
End If
ActiveSheet.ShowAllData

End Sub

Mike F
"matthias" wrote in message
ups.com...
Hello guys,

I apply a autofilter in my macro. It filters a range in column a with
criteria ="Y". Then I want to copy the lines in column a who fulfill
this criteria to a new sheet (also in column a)


what is the command for this?

thankx





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

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