How to copy data to another worksheet with Advanced Filter in Excel?
Normally, we can quickly apply the Advanced Filter feature to extract data from the raw data in the same worksheet. But, sometimes, when you try to copy the filtered result to another worksheet, you will get the following warning message. In this case, how could you deal with this task in Excel?
Here is a simple workaround for you to solve this job, please do as this:
1. Activate the worksheet where you want to copy the filtered result by using the Advanced Filter function.
2. Then click Data > Advanced, see screenshot:
3. In the Advanced Filter dialog box, select Copy to another location from the Action section, and then click button to select the data range which you want to filter in another sheet beside the List range, go on clicking button beside the Criteria range to select the criteria from another sheet, see screenshot:
4. Then click button beside the Copy to box to select a cell where you want to output the filtered result from the active sheet, and then click OK button, the filtered result has been extracted into another sheet based on your original data sheet.
If you are skilled with VBA code, you can finish this job with following VBA code.
1. Activate the worksheet which you want to filter and copy the result to another sheet.
2. Hold down the ALT + F11 keys in Excel, and it opens the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Copy data to another worksheet with Advanced Filter:
Sub Advancedfiltertoanothersheet() 'Updateby Extendoffice Dim xStr As String Dim xAddress As String Dim xRg As Range Dim xCRg As Range Dim xSRg As Range On Error Resume Next xAddress = ActiveWindow.RangeSelection.Address Set xRg = Application.InputBox("Please select the filter range:", "Kutools for Excel", xAddress, , , , , 8) If xRg Is Nothing Then Exit Sub Set xCRg = Application.InputBox("Please select the criteria range:", "Kutools for Excel", "", , , , , 8) If xCRg Is Nothing Then Exit Sub Set xSRg = Application.InputBox("Please select the output range:", "Kutools for Excel", "", , , , , 8) If xSRg Is Nothing Then Exit Sub xRg.AdvancedFilter xlFilterCopy, xCRg, xSRg, False xSRg.Worksheet.Activate xSRg.Worksheet.Columns.AutoFit End Sub
4. And then press F5 key to run this code, and a prompt box is popped out to let you select the data range that you want to filter, see screenshot:
5. Then click OK, and another dialog box is popped out to remind you to select the criteria range you want to filter based on, see screenshot:
6. Go on clicking OK, in the popped out dialog box, please select a cell from another new worksheet where you want to output the filter result, see screenshot:
7. At last, click OK button, the filtered data has been outputted into another specified sheet as you need.