filtered macro including top row

how can i edit the below filter to include the top row (header)?

Thanks.

Private Sub ExtractFiltered(ByVal Flt As String, _
                            ws As Worksheet)
    ' Create new sheet and paste total from filter 'Flt"
    
    Dim NewWs As Worksheet
    Dim CurrWs As Worksheet
    Dim Rg As Range
    Dim Col As Long
    
    Set CurrWs = ActiveSheet
    Set NewWs = BlankSheet(Flt)

    Set Rg = ws.Range("O1").CurrentRegion
    With Rg
        Col = ws.Range("O:O").Column - .Column + 1
        .AutoFilter
        .AutoFilter Field:=Col, Criteria1:=Flt
        .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).Copy
    End With
    
    NewWs.Cells(1, 1).PasteSpecial xlPasteValues
    WriteColumnTotal 1, NewWs
    NewWs.Columns.AutoFit
    Rg.AutoFilter

    On Error Resume Next
    CurrWs.Activate
End Sub

Open in new window

eastsidemarketAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andrewssd3Commented:
Private Sub ExtractFiltered(ByVal Flt As String, _
                            ws As Worksheet)
    ' Create new sheet and paste total from filter 'Flt"
    
    Dim NewWs As Worksheet
    Dim CurrWs As Worksheet
    Dim Rg As Range
    Dim Col As Long
    
    Set CurrWs = ActiveSheet
    Set NewWs = BlankSheet(Flt)

    Set Rg = ws.Range("O1").CurrentRegion
    With Rg
        Col = ws.Range("O:O").Column - .Column + 1
        .AutoFilter
        .AutoFilter Field:=Col, Criteria1:=Flt
        '.Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).Copy
        .Copy
    End With
    
    NewWs.Cells(1, 1).PasteSpecial xlPasteValues
    WriteColumnTotal 1, NewWs
    NewWs.Columns.AutoFit
    Rg.AutoFilter

    On Error Resume Next
    CurrWs.Activate
End Sub

Open in new window

Without seeing your sheet, I don't know your data, but you should just be able to copy the whole range as above - it is the offset and resize that are removing the top row.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eastsidemarketAuthor Commented:
perfect - thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.