Exclude header row when copying autofilter results? (XL2003)

K

ker_01

I'm looping through code that updates an autofilter, and then I copy the
autofiltered data to a target sheet (hundreds of times). The problem is that
it is also copying the header row, and as I add each chunk of data to my
destination sheets, I've got unwanted repeating header rows throughout the
data.

Is there a good way to select the autofiltered rows while excluding just the
header row? When I record my desired activity via macro, is selects the first
row, which will vary depending on what data I'm autofiltering on in each loop.

Current code:
Sheet2.Activate
Sheet2.Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:=SortableTempVal
Sheet2.Cells.Select
Selection.Copy

Recorded macro selecting the visible rows excluding the header row:
Rows("752:752").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

If there isn't a good way, I suppose I can write some less elegant code to
delete the first pasted row in each destination worksheet, but I was hoping
to learn something new today :)

Thanks!
Keith
 
D

Don Guillett

try this idea
Sub copyfiltereddataSAS()
Set ss = Sheets("sheet15")
Set ds = Sheets("sheet14").range("a17")
With ss
.Cells.AutoFilter Field:=2, Criteria1:="no" 'SortableTempVal
.UsedRange.SpecialCells(xlCellTypeVisible).Copy ds
.Cells.AutoFilter
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top