This article will tell you how to import filtered excel rows from one excel file into a new excel workbook. And when the source excel rows data is changed, the data in new excel workbook will also be changed dynamically by refresh the connection. There are two method to achieve this, i will introduce them one by one.
1. Use Power Query Editor To Dynamically Import Data From One Excel File To Another.
- Import data from source excel file to target excel file follow article How To Import ( Export ) Excel WorkBook From ( To ) Excel, CSV, Text, Html and Pdf Format File.
- In the Navigator window of import from excel file process, there is a Transform Data button after the Load drop-down list.
- Click the Transform Data button will open the Power Query Editor window. You can execute sort, filter and other data clean actions in Power Query Editor to get the rows or columns data that you want.
- You can click the down arrow at each column’s right side to open a popup window, and it provides sort, filter, compare functions in that window.
- After you edit the query condition, click the Power Query Editor‘s File —> Close & Load menu item to close the Power Query Editor and load the filtered out data rows into a new excel worksheet.
- Now you can see your desired rows in the new worksheet left side, and there is also a Workbook Queries list pane in worksheet right side. It list all the queries that you have created. You can right-click one query and then execute operations like edit, delete, rename, refresh etc in the popup menu list.
- If above Workbook Query related source excel file data is changed, and when you click Refresh menu item in above menu list, you can find the rows in new excel worksheet is also changed accordingly.
2. Use Microsoft Query To Dynamically Import Data From One Excel File To Another.
2.1 Create Excel Named Data Range.
- Select the cell range which you want to export in the source excel file worksheet.
- Then click Formulas —> Define Name ( drop down list) —> Define Name to give the cell range a name.
- Input a name ( ie : ExampleCellRange ) in the popup window Name text box. In the Scope selection list, select which worksheet or entire workbook that the named cell range is visible. Click OK button to save it.
2.2 Create Excel Table Based On Above Named Data Range.
- Click Insert tab at top of excel ribbon area.
- Select the data range name ( ExampleCellRange ) from the first drop down list. Then it will select all the cells that this named data range defined.
- Click Table button in the Insert tab. Check the My table has headers checkbox in the popup Create Table window and click OK to save it.
- Now it will go to Table Tools —> Design tab automatically. You can change the table name at the beginning of left side Properties area.
- Please note the table and named data range points to same data set. But you should define the table first to execute below query process.
2.3 Execute Microsoft Query In Another Excel File To Import Above Table Data.
- Create a new excel workbook, click Data tab —> From Other Sources —> From Microsoft Query.
- Select Excel Files* in the popup Choose Data Source dialog Databases tab, click OK button.
- Browse to select the source excel workbook which you define the table in the popup window. Click OK button.
- Because we have defined a table already, so it will list the named data range of the table in the next Query Wizard – Choose Columns window.
- You should move wanted columns from left side Available tables and columns list to right side Columns in your query list. Then click Next button to continue.
- In the next Query Wizard – Filter Data widow, you can filter rows by each column condition.
- In my example, i add a filter condition on Units Sold column, only get rows which Units Sold columns value is greater than 1000. Click Next button to continue.
- In the next Query Wizard – Sort Order window, you can specify how your rows sorted by column.
- Click Next button in above dialog will get you to the Query – Wizard – Finish window. You can choose Return Data to Microsoft Excel or View data or edit query in Microsoft Query radio button. You can also click Save Query button to save the query.
- If you select the first radio button, when you click Finish button, it will popup Import Data dialog.
- Click OK button will add all the filtered rows into the new worksheet.
- Now suppose you remove two rows ( which Units Sold column value is greater than 1000) from the source excel file table. And when you click the Table Tools —> Design tab —> Refresh button in the new excel file worksheet, you will find the two rows has also disappear from the table. This means you can import the data dynamically.