Reputation: 75
I want to write one macro it should work like Excel filter. After getting all the data using this filter I want to paste in to the new worksheet.
Upvotes: 0
Views: 1431
Reputation: 1477
This sub filter zero values in sheet1 and copy to sheet2 range A1
Sub FilterAndCopy()
'Developer by Bruno Leite
'http://officevb.com
Dim Sht As Worksheet
Dim FilterRange As Range
'Set your Sheet
Set Sht = ThisWorkbook.Sheets("Sheet1")
'Verify if is Filter
If Sht.FilterMode Then
Sht.ShowAllData
End If
'Filter Column A with 0 at parameter
Sht.Range("A:A").AutoFilter Field:=1, Criteria1:="0"
'Define Range Of Visible cells without row title
Set FilterRange = Sht.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells(xlCellTypeVisible)
FilterRange.Copy Sheets("Sheet2").Range("A1")
Sht.ShowAllData
End Sub
[]´s
Upvotes: 1