You can refresh an external data range automatically when you open the workbook, and optionally save the workbook without saving the external data, so that the workbook file size is reduced.
- Click a cell in the external data range you want to refresh, and then click Data Range Properties on the External Data toolbar.
- Select the Refresh data on file open check box.
- If you want to save the workbook with the query definition but without the external data, select the Remove external data from worksheet before saving check box.
Refresh multiple external data ranges
- If your worksheet contains more than one external data range that you want to refresh, on the View menu, point to Toolbars, and click External Data.
- On the External Data
toolbar, click Refresh All
to refresh all of the external data ranges in the workbook.
If you have more than one workbook open, you must click Refresh All in each workbook to refresh external data.
Refresh data in an imported text file
- Select the worksheet with your imported text file.
- Click Refresh Data on the External Data toolbar.
- In the Import Text File dialog box, select your text file, and then click Import.
If you want to import only part of the data in a text file as a refreshable data range, you can create a query to retrieve the data. For more information, see Microsoft Query Help.
Automatically refresh data at intervals
- Click a cell in the external data range, and then click Data Range Properties on the External Data toolbar.
- Select the Refresh every box, and then enter the number of minutes between refreshes.
Control the order of refreshes
- Click a cell in the external data range you want to refresh first, and then click Refresh Data on the External Data toolbar.
- Repeat for each external data range until they are all refreshed in the order you want.
Setting refresh options
Require a password to refresh an external data range
If your data source requires a password to connect to it, you can require that the password is entered before the external data range can be refreshed. This procedure does not apply to data retrieved from a text file (*.txt) or a Web query (*.iqy).
- Click a cell in the external data range, and then click Data Range Properties on the External Data toolbar.
- Under Query definition, clear the Save password check box.
Notes
- Stored passwords are not encrypted.
-
Microsoft Excel prompts for the password only the first time that the external data range is refreshed in each Excel session. The next time you start Excel, you will be prompted for the password again if you open the workbook that contains the query, and then click Refresh Data .
Preserve cell formatting when you refresh an external data range
- Click a cell in the external data range, and then click Data Range Properties on the External Data toolbar.
- Do one or both of the following
- If you want to preserve cell formatting that you apply, select the Preserve cell formatting check box under Data formatting and layout.
-
If you want to preserve column widths that you set, clear the Adjust column width check box under Data formatting and layout.
- Click OK.
- To refresh the external data range, click Refresh Data on the External Data toolbar.
Run a query in the background or while you wait
Running a query in the background allows you to use Microsoft Excel while the query runs.
- Click a cell in the external data range, and then click Data Range Properties on the External Data toolbar.
- Select the Enable background refresh check box to run the query in the background or clear it to run the query while you wait.
Notes
- Stop a query To stop a query from running when Enable background refresh is turned off, press ESC.
- Stop a background refresh To stop a query that is running in the background, double-click the Background Refresh icon on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.
- Recording a macro While you are recording a macro that includes a query, Excel will not run the query in the background. To change the recorded macro so that it runs in the background, edit the macro in the Visual Basic Editor and change the refresh method for the QueryTable object from "BackgroundQuery := False" to "BackgroundQuery := True". For information about editing macros, see Visual Basic Help.
Note You can check the status of a refresh by clicking Background Refresh in the status bar. To cancel the query, click Cancel Refresh on the External Data toolbar.