Given a data set, that is lets say 10 columns. In column A i have date and in column B i have %. I want to filter for column A only 2014 data and for column B <70% and copy paste the filtered data into another worksheet. How do i go about writing the code for the next line to get to the first row of filtered data?
ActiveSheet.Range("$A$1:$AR$1617").AutoFilter Field:=5, Operator:= _
xlFilterValues, Criteria2:=Array(0, "12/28/2014")
ActiveSheet.Range("$A$1:$AR$1617").AutoFilter Field:=14, Criteria1:="<0.7" _
, Operator:=xlAnd
Copies only the visible/filtered cells to a new worksheet as the first part of your question requests.
To get the first line of data, presuming there is data and you have headers in line 1, and paste that to a new sheet's next available row.
And a loop solution, that will copy data from sheet1 to sheet2, providing that column A always contains data (will be a bit slow on very large data sets):
Call using:
Use
Offset
method like this:Above code copies the filtered data excluding the header.
Is this what you're trying?