Filter and paste from a table to another worksheet

Jamuson

New Member
Joined
Dec 18, 2020
Messages
8
Platform
  1. MacOS
I am trying to paste filtered data into another worksheet. The issue I'm having is that excel will paste the entireRow and not just columns A:M into the new sheet.
My data starts at A:5 to M5 on the source sheet and I want to only paste "rows" (A5:M5) in which column G contains "PLG", skipping sequentially to the next open row in the destination worksheet.

1688233064520.png

This is the source sheet layout, and the destination sheet is identical. My source sheet has other information in adjacent cells to the right of column M. I also want to keep the destination formatting and just paste the values. I would like this to happen automatically or with a macro, any ideas?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hello Jamuson,

See if the following code helps:-

VBA Code:
Sub Test()

    Application.ScreenUpdating = False
    
        With Sheet1.Range("G4", Sheet1.Range("G" & Sheet1.Rows.Count).End(xlUp))
                .AutoFilter 1, "PLG"
                .Offset(1, -6).Resize(.Rows.Count - 1, 13).Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
                .AutoFilter
        End With
    
    Application.ScreenUpdating = True

End Sub

I'm assuming that your headings are in row 4. I've used sheet codes(Sheet1 and Sheet2) as the source/destination sheets. This may have to be altered to suit.

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Not quite, this filters on sheet1 column A and pastes all values from sheet1, not just the PLG's on sheet2 and they are pasted in row 70 not starting at row 5
 
Upvote 0
It appears then that you are using a formal Excel table. Hence, try it as follows:-

VBA Code:
Sub Test()

    Application.ScreenUpdating = False
    
        With Sheet1.ListObjects("Table1").Range
                .AutoFilter 7, "PLG"
                .Columns("A:M").Offset(1).Resize(.Rows.Count - 1).Copy
                Sheet2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlValues
                .AutoFilter
        End With
    
    Application.ScreenUpdating = True

End Sub

You may have to change the table name to suit.
Are the filtered values going to a formal table in sheet2 as well?

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top