How to copy data to another worksheet with Advanced Filter in Excel?
The Advanced Filter feature in Excel allows you to extract and filter data from a dataset. While it works seamlessly within the same worksheet, you may encounter a warning message when attempting to copy the filtered results to another worksheet. In this guide, we will show you step-by-step how to copy filtered data to another worksheet using both the Advanced Filter feature and VBA code.
Copy data to another worksheet with Advanced Filter by using Advanced Filter feature
Copy data to another worksheet with Advanced Filter by using VBA code
Copy data to another worksheet with Advanced Filter by using Advanced Filter feature
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.
Copy data to another worksheet with Advanced Filter by using VBA code
If you are skilled with VBA, you can complete this task using the 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. Click OK, and another dialog box will appear, prompting you to select the criteria range for filtering, as shown in the 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.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!