Thread
:
Exclude header row when copying autofilter results? (XL2003)
View Single Post
#
1
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Exclude header row when copying autofilter results? (XL2003)
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
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"ker_01" wrote in message
...
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
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett