Copy and paste filtered data into another worksheet

Rek88

New Member
Joined
Jun 4, 2019
Messages
2
I have a spreadsheet full of data in multiple columns. I want to filter on two of the columns on a few criteria and then send the results to other worksheets.

So for example, each time I have country a, county b and country c in column A (book titles) as well as author a and Author b In column B (authors) - these get copied and sent off to worksheet A

each time I have country d, county e and country f in column A (book titles) as well as author c and Author d In column B (authors) - these get copied and sent off to worksheet B.

If I go back and decide to change the data in the original data set, I want the copied data to reflect the change.

Is there any easy way to do this in vba or an advance filter?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try this

Run macro Copy_filtered_data.
Change data in red by your information.

Code:
Sub Copy_filtered_data()
    Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
    dim country, authors 
    Set sh1 = Sheets("[COLOR=#ff0000]data[/COLOR]")
    Set sh2 = Sheets("[COLOR=#ff0000]Sheet A"[/COLOR])
    Set sh3 = Sheets("[COLOR=#ff0000]Sheet B[/COLOR]")
        
    country = Array([COLOR=#ff0000]"country a", "country b", "country c"[/COLOR])
    authors = Array("[COLOR=#ff0000]author a", "author b[/COLOR]")
    Call filter_data(sh1, country, authors, sh2)


    country = Array("[COLOR=#ff0000]country d", "country e", "country f[/COLOR]")
    authors = Array("[COLOR=#ff0000]author c", "author d"[/COLOR])
    Call filter_data(sh1, country, authors, sh3)


End Sub


Sub filter_data(sh1, country, authors, sh)
    sh1.Range("A1").AutoFilter 1, country, xlFilterValues
    sh1.Range("A1").AutoFilter 2, authors, xlFilterValues
    sh1.AutoFilter.Range.EntireRow.Copy sh.Range("A1")
    sh1.ShowAllData
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,567
Messages
6,120,268
Members
448,953
Latest member
Dutchie_1

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