How to Use Advanced Filter to Copy Data to Another Sheet in Excel

In this article, we will demonstrate two methods to apply the Advanced Filter to copy data to another sheet in Excel. In the first method, we will use the Advanced option from the Data tab, and in the second, we will apply VBA code to activate the Advanced Filter option, then copy data to a different sheet.


Method 1 – Copying Data to Another Worksheet with the Advanced Filter Feature

We can use the advanced filter criteria in the Advanced option on the Excel ribbon to copy data to another sheet in Excel. The Advanced option is located in the Data tab under the section named “Sort & Filter”.

In the following dataset, we have the “Last Name”, “Sales Amount”, and City for different salespersons. We’ll copy the data only for the salespersons with the last name Smith and Jones to a sheet named “Copy Sheet”.

Steps:

  • Go to the sheet named “Copy Sheet” (the destination sheet, where the data will be pasted).
  • Go to the Data tab in that sheet.
  • Click on the Advanced option from the section “Sort & Filter”.

Copy Data to Another Worksheet with Advanced Filter Feature

  • A new dialog box named “Advanced Filter” will appear.

Copy Data to Another Worksheet with Advanced Filter Feature

  • Check the option “Copy to another location”.
  • Click on the “List range” input box and go to the sheet named “Actual Sheet”.

Copy Data to Another Worksheet with Advanced Filter Feature

  • In that sheet, select the range B4:D15.

The range (B4:D15) is selected in the “List range” input box, whose value should look like this:

List range: ‘Actual Sheet’!$B$4:$D15

  • Set the following values in the “Advanced Filter” dialog box:

Criteria range: ‘Actual Sheet’!$F$9:$F$11

Copy to: ‘Copy Sheet’!$B$4

  • Click OK.

The highlighted rows are copied from the sheet named “Actual Sheet” to the sheet named “Copy Sheet”.

Copy Data to Another Worksheet with Advanced Filter Feature


Method 2 – Using the Advanced Filter with VBA Code to Copy Data to Another Worksheet

We can also apply Advanced Filter with VBA code to copy data to another sheet. Basically, in this method we will do exactly the same thing as in the first Method, but this time apply a VBA code to activate the functionality of the Advanced Filter option.

Apply Advanced Filter with VBA Code to Copy Data to Another Worksheet

Steps:

  • Select the destination sheet “Copy Sheet-2”.
  • Right-click on the sheet name and select the option “View Code”.

Apply Advanced Filter with VBA Code to Copy Data to Another Worksheet

A blank VBA module will appear.

  • Insert the following code in the blank module:
Sub Advance_Filter_to_Copy_to_Another_Sheet()
Dim Str As String
Dim Address As String
Dim Rg As Range
Dim CRg As Range
Dim SRg As Range
On Error Resume Next
xAddress = ActiveWindow.RangeSelection.Address
Set Rg = Application.InputBox("Please select the filter range:", "Copy to Another Sheet", xAddress, , , , , 8)
If Rg Is Nothing Then Exit Sub
Set CRg = Application.InputBox("Please select the criteria range:", "Copy to Another Sheet", "", , , , , 8)
If CRg Is Nothing Then Exit Sub
Set SRg = Application.InputBox("Please select the output range:", "Copy to Another Sheet", "", , , , , 8)
If SRg Is Nothing Then Exit Sub
Rg.AdvancedFilter xlFilterCopy, CRg, SRg, False
SRg.Worksheet.Activate
SRg.Worksheet.Columns.AutoFit
End Sub
  • Press F5 or click on the Run button to run the code.

Apply Advanced Filter with VBA Code to Copy Data to Another Worksheet

A new dialog box opens named “Copy to Another Sheet”.

Apply Advanced Filter with VBA Code to Copy Data to Another Worksheet

  • Click on the input box, go to the sheet named “VBA” and select the range B4:D15.
  • Click OK.

Another dialog box will appear, in which we’ll insert the criteria range.

  • Click on the input box, select the sheet name “VBA“, and from that sheet select the range F9:F11.

The above actions will create a value in the input box like this:

VBA!$B$4:$D$15

  • Click OK.

Another dialog box for the output range opens.

  • Select cell B4 in the destination sheet.

This will insert the value $B$4 in the input box.

  • Click OK

All the highlighted rows are copied to another sheet.

Apply Advanced Filter with VBA Code to Copy Data to Another Worksheet


Download Practice Workbook


<< Go Back to Advanced Filter | Filter in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Mukesh Dipto
Mukesh Dipto

Mukesh Dipto is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including Rhino3D, Maxsurf C++, AutoCAD, HTML, CSS, JavaScript, and WordPress. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo