Excel connections not refreshing

To keep imported external data up-to-date, you can refresh it to see recent updates and deletes. Excel provides many options for refreshing data, including when you open the workbook and at timed intervals.

Note: To stop a refresh, press Esc. To refresh a worksheet, press  Ctrl + F5. To refresh a workbook, press Ctrl + Alt + F5.

 Learn about refreshing data in the Excel app

The following table summarizes the refresh actions, shortcut keys, and commands.

To

Press

Or

Refresh selected data in the worksheet

Alt + F5

Select Data > The drop-down arrow next to Refresh All > Refresh

Mouse pointing to the Refresh command on the ribbon

Refresh all data in the workbook

Ctrl + Alt + F5

Select Data > Refresh All

Mouse pointer over the Refresh All button

Check refresh status

Double-click the message, «Retrieving Data» on the status bar.

Message box: Retrieving Data

Stop a refresh

Esc

Message displayed when refreshing and command to use to stop the refresh (ESC)

Stop a background refresh

Double-click the message on the status bar.

Message box: Background refresh

And then select Stop Refresh in the External Data Refresh Status dialog box.

External Data Refresh Status dialog box

Data in a workbook may be stored directly in the workbook, or it may be stored in an external data source, such as a text file, a database, or the cloud. The first time you import external data, Excel creates connection information, sometimes saved to an Office Data Connection (ODC) file, which describes how to locate, log in, query, and access the external data source.

When you are connected to an external data source, you can perform a refresh operation to retrieve the updated data. Each time that you refresh data, you see the most recent version of the data, including any changes that were made to the data since it was last refreshed.

Learn more about refreshing data

This explains the basic process of what happens when you refresh data connected to an external data source:

  1. Someone starts refreshing the workbook’s connections to get up-to-date data.

  2. Connections are made to external data sources that are used in the workbook.

    Note: There are a variety of data sources you can access, such as OLAP, SQL Server, OLEDB providers, and ODBC drivers.

  3. The data in the workbook is updated.

The basic process of refreshing external data

Learn about security concerns

When you are connected to an external data source and you attempt to refresh the data, it’s important to be aware of potential security issues, and to know what you can do about any security issues.

Trust Connections    — External data may be currently disabled on your computer. To refresh the data when you open a workbook, you must enable the data connections by using the Trust Center bar, or you must place the workbook in a trusted location. For more information, see these articles:

  • Add, remove, or modify a trusted location for your files

  • Trusted documents

  • Add, remove, or view a trusted publisher

  • View my options and settings in the Trust Center.

ODC file    — A data connection file (.odc) often contains one or more queries that are used to refresh external data. By replacing this file, a user who has malicious intent can design a query to access confidential information and distribute it to other users or perform other harmful actions. Therefore, it’s important to ensure that the connection file was authored by a reliable individual, and the connection file is secure and comes from a trusted Data Connection Library (DCL).

Credentials    — Accessing an external data source usually requires credentials (such as a user name and a password) that are used to authenticate the user. Make sure that these credentials are provided to you in a safe and secure manner, and that you do not inadvertently reveal these credentials to others. If your external data source requires a password to gain access to the data, you can require that the password is entered each time the external data range is refreshed.

Sharing —    Are you sharing this workbook with other people who might want to refresh data? Help your colleagues avoid data refresh errors by reminding them to request permissions on the data sources providing the data.

For more information, see Manage data source settings and permissions.

You can refresh an external data range automatically when you open the workbook. You can also save the workbook without saving the external data to shrink the size of the file.

  1. Select a cell in the external data range.

  2. Select Data > Queries & Connections > Connections tab, right click a query in the list, and then select Properties.

  3. In the Connection Properties dialog box, on the Usage tab, under Refresh control, select the Refresh data when opening the file check box.

  4. If you want to save the workbook with the query definition but without the external data, select the Remove data from the external data range before saving the workbook check box.

  1. Select a cell in the external data range.

  2. Select Data > Queries & Connections > Connections tab, right click a query in the list, and then select Properties.

  3. Click the Usage tab.

  4. Select the Refresh every check box, and then enter the number of minutes between each refresh operation.

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. Consider running a background refresh. This returns control of Excel to you instead of making you wait several minutes or more for the refresh to finish.

Note: You can’t run an OLAP query in the background and you can’t run a query for any connection type that retrieves data for the Data Model.

  1. Select a cell in the external data range.

  2. Select Data > Queries & Connections > Connections tab, right click a query in the list, and then select Properties.

  3. Select the Usage tab.

  4. Select the Enable background refresh check box to run the query in the background. Clear this check box to run the query while you wait.

    Tip    While you record a macro that includes a query, Excel doesn’t run the query in the background. To change the recorded macro so that the query runs in the background, edit the macro in the Visual Basic Editor. Change the refresh method for the QueryTable object from BackgroundQuery := False to BackgroundQuery := True.

Stored passwords aren’t encrypted, so they’re not recommended. If your data source needs a password to connect to it, you can require that users enter the password before they can refresh the external data range. The following procedure doesn’t apply to data retrieved from a text file (.txt) or a Web query (.iqy).

Tip: Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don’t mix these elements. For example, Strong password: Y6dh!et5. Weak password: House27. Passwords should be 8 or more characters in length. A pass phrase that uses 14 or more characters is better.

It’s critical that you remember your password. If you forget your password, Microsoft cannot retrieve it. Store the passwords that you write down in a secure place away from the information that they help protect.

  1. Select a cell in the external data range.

  2. Select Data > Queries & Connections > Connections tab, right click a query in the list, and then select Properties.

  3. Select the Definition tab, and then clear the Save password check box.

Note: Excel prompts you 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’ll be prompted for the password again if you open the workbook that contains the query and then attempt a refresh operation.

Detailed help for refreshing data

When you shape your data in Power Query, you typically load the changes to a worksheet or Data Model. It’s important to understand the difference when you are refreshing data and how you refresh it.

Note: When you refresh, new columns added since the last refresh operation are added to Power Query. To see these new columns, re-examine the Source step in the query. For more information, see Create Power Query formulas.

Most queries are based on external data resources of one kind or another. However, there is a key difference between Excel and Power Query. Power Query caches the external data locally to help improve performance.  Furthermore, Power Query doesn’t automatically refresh the local cache to help prevent incurring costs for data sources in Azure.

Important: If you receive a message in the yellow message bar at the top of your window, that states “This preview may be up to n days old.”, it usually means the local cache is out-of-date. You should select Refresh to bring it up-to-date.

Refresh a query in the Power Query Editor

When you refresh a query from the Power Query Editor, you are not only bringing in updated data from the external data source, you are also updating the local cache. But this refresh operation does not update the query in the worksheet or Data Model.

  1. In Power Query Editor, select Home

  2. Select Refresh Preview > Refresh Preview (the current query in Preview Data) or Refresh All (all opened queries from the Queries pane.)

  3. At the bottom of the Power Query Editor on the right, a message displays, “Preview downloaded at <hh:mm> AM/PM”. This message displays upon first importing, and after each subsequent refresh operation in the Power Query Editor.

Refresh a query in a worksheet

  1. In Excel, select a cell in a query in a worksheet.

  2. Select the Query tab in the ribbon, and then select Refresh > Refresh.

  3. The worksheet and the query are refreshed from the external data source and the Power Query cache.

Notes: 

  • When you refresh a query that was imported from an Excel table or named range, pay attention to your current worksheet. If you want to change the data in the worksheet that contains the Excel table, make sure you have selected the correct worksheet and not the worksheet that contains the loaded query.

  • This is especially important if you are changing the column headers in the Excel Table. They often look similar and it’s easy to confuse the two. It’s a good idea to rename the worksheets to reflect the difference. For example, you could rename them to “TableData” and “QueryTable” to emphasize the distinction.

At any time, you can select Refresh to update the data for the PivotTables in your workbook. You can refresh the data for PivotTables connected to external data, such as a database (SQL Server, Oracle, Access, or other), Analysis Services cube, data feed, as well as data from a source table in the same or a different workbook. PivotTables can be refreshed manually or automatically when you open the workbook.

Manually refresh

  1. Select the anywhere in the PivotTable to show the PivotTable Analyze tab in the ribbon.

    Note: To refresh a PivotTable in Excel for the web, right-click anywhere on the PivotTable, and then select Refresh.

  2. Select Refresh or Refresh All.
    Refresh button on the Analyze tab

  3. To check the refresh status if refreshing takes longer than you expect, select the arrow under Refresh > Refresh Status.

  4. To stop refreshing, select Cancel Refresh, or press Esc.

Prevent column widths and cell formatting from adjusting

If the column widths and cell formatting of your data adjust when you refresh the PivotTable data, and you don’t want that to happen, make sure the following options are checked:

  1. Select the anywhere in the PivotTable to show the PivotTable Analyze tab in the ribbon.

  2. Select the PivotTable Analyze tab > in the PivotTable group, select Options.

    Options button on the Analyze tab

  3. On the Layout & Format tab > select the checkboxes for Autofit column widths on update and Preserve cell formatting on update.

Refresh data automatically when opening the workbook

  1. Select the anywhere in the PivotTable to show the PivotTable Analyze tab in the ribbon.

  2. Select the PivotTable Analyze tab > in the PivotTable group, select Options.

    Options button on the Analyze tab

  3. On the Data tab, select Refresh data when opening the file.

Refreshing an offline cube file, which recreates the file by using the most recent data from the server cube, can be time consuming and require a lot of temporary disk space. Start the process at a time when you don’t need immediate access to other files in Excel, and make sure you have adequate disk space to save the file again.

  1. Select the PivotTable connected to the offline cube file.

  2. On the Data tab, in the Queries & Connections group, click the arrow under Refresh All, and then click Refresh.

For more information, see Work with offline cube files.

  1. On the worksheet, click a mapped cell to select the XML map that you want to refresh.

  2. If the Developer tab isn’t available, do the following to display it:

    1. Click File, click Options, and then click Customize Ribbon.

    2. Under Main Tabs, select the Developer check box, and then click OK.

  3. On the Developer tab, in the XML group, click Refresh Data.

For more information, see Overview of XML in Excel.

When you refresh a Data Model in Power Pivot , you can also see whether your refresh succeeds, fails, or is cancelled. For more information, see Power Pivot: Powerful data analysis and data modeling in Excel.

Note: Addition of data, changing data, or editing filters always triggers recalculation of DAX formulas that depend on that data source.

Refresh and view the status of refresh   

  1. In Power Pivot, select Home > Get External Data > Refresh or Refresh All to refresh the current table or all of the tables in the Data Model.

  2. Status of the refresh is indicated for each connection used in the data model. There are three possible outcomes:

  • Success — Reports on the number of rows imported into each table.

  • Error — Occurs if the database is offline, you no longer have permissions, or a table or column is deleted or renamed in the source. Verify the database is available, perhaps by creating a new connection in a different workbook.

  • Cancelled — Excel did not issue the refresh request, probably because refresh is disabled on the connection.

Use table properties to show the queries used in data refresh

Data refresh is simply rerunning the same query that was used to get the data in the first place. You can view, and sometimes modify, the query by viewing table properties in the Power Pivot window.

  1. To view the query used during data refresh, select Power Pivot > Manage to open the Power Pivot window.

  2. Select Design > Table Properties.

  3. Switch to Query Editor to view the underlying query.

Queries are not visible for every type of data source. For example, queries are not shown for data feed imports.

Set connection properties to cancel data refresh

In Excel, you can set connection properties that determine the frequency of data refresh. If refresh is not allowed on a particular connection, you’ll get a cancellation notice when you run Refresh All or attempt to refresh a specific table that uses the connection.

  1. To view connection properties, in Excel, select Data > Queries & Connections to view a list of all connections used in the workbook.

  2. Select the Connections tab, right-click a connection, and then click Properties.

  3. In the  Usage tab, under Refresh control, if the checkbox is cleared for Refresh this connection on Refresh All, you will get a cancellation when you try Refresh All in the Power Pivot window.

Refresh data on SharePoint Server 2013

On SharePoint Server, you can schedule unattended data refresh on the server, but doing so requires that Power Pivot for SharePoint 2013 is installed and configured in your SharePoint environment. Check with your SharePoint administrator to find out if scheduled data refresh is available. For more information, see Configure scheduled data refresh for Power Pivot.

When the data you use for your map changes, you can refresh it manually in 3D Maps. The changes will then be reflected on your map. Here’s how:

  • In 3D Maps, select Home > Refresh Data.

    Refresh Data on the Home tab

Add data to Power Map

To add new data to your 3D MapsPower Map:

  1. In 3D Maps, go to the map you want to add data to.

  2. Leave the 3D Maps window open.

  3. In Excel select the worksheet data you want to add.

  4. On the Excel ribbon, click Insert > Map arrow > Add Selected Data to Power Map. Your 3D Maps will automatically update to show the additional data. For more information, see Get and prep your data for Power Map.

    Add Selected Data to Power Map command

Refreshing external data in Excel Services has unique requirements.

Control how data is refreshed

You can control how to refresh data from an external data source by doing one or more of the following.

Refresh on open with    

Excel Services

In Excel, you can create a workbook that automatically refreshes external data when the file is opened. In this case, Excel Services always refreshes the data before it displays a workbook and creates a new session. Use this if you want to ensure that up-to-date data is always displayed when you open the workbook in Excel Services.

  1. In a workbook with external data connections, select the Data tab.

  2. In the Connections group, select Connections > select the connection > Properties.

  3. Select the Usage tab and then select Refresh data when opening the file.

    Warning: If you clear the Refresh data when opening the file check box, the data that is cached with the workbook is displayed, which means that when a user manually refreshes the data, the user sees up-to-date data during the current session, but the data is not saved to the workbook.

Refresh with an .odc file

If you are using an Office Data Connection file (.odc), make sure you also set the Always use connection file check box:

  1. In a workbook with external data connections, select the Data tab.

  2. In the Connections group, select Connections > select the connection > Properties.

  3. Select the Definition tab and then select Always use connection file.

The trusted file location site settings, Short Session Timeout and External Data Cache Lifetime, can also have an impact on refresh operations. For more information, see your administrator or the Help system.

Manual refresh   

  1. Select a cell in the PivotTable report.

  2. On the Excel Web Access toolbar, under the Update menu, select Refresh Selected Connection.

    Notes: 

    • If this Refresh command is not visible, then the Web Part author has cleared the Refresh Selected Connection, Refresh All Connections property. For more information, see Excel Web Access Web Part custom properties.

    • Any interactive operation that causes a re-query of an OLAP data source initiates a manual refresh operation.

  • Refresh all connections — On the Excel Web Access toolbar, under the Update menu, click Refresh All Connections.

  • Periodic refresh — You can specify that data automatically refreshes at a specified interval after the workbook is opened for each connection in the workbook. For example, an inventory database may be updated every hour, and so the workbook author has defined the workbook to automatically refresh every 60 minutes.

    A Web Part author can select or clear the Allow Excel Web Access Periodic Data Refresh property to allow or prevent periodic refresh. When the time interval elapses, by default, you’ll see a refresh alert display at the bottom of the Excel Web Access Web Part. 

    An Excel Web Access Web Part author can also set the Display Periodic Data Refresh Prompt property to control the behavior of the message that is displayed when Excel Services performs a periodic data refresh during a session:

    For more information, see Excel Web Access Web Part custom properties.

  • Always — means that the message is displayed with a prompt at each interval.

  • Optionally — means that a user can choose to continue periodic refresh without displaying a message.

  • Never — means that Excel Web Access performs a periodic refresh without displaying a message or prompt.

  • Cancel a refresh — While the workbook is refreshing, Excel Services displays a message with a prompt because it could take longer than you expect. You can select Cancel to stop refreshing so you can finish it later at a more convenient time. Data returned by queries before you canceled the refresh will display.

When you use a workbook in the browser, you are viewing data that is stored directly in the workbook or external data where the data is stored elsewhere and requires a connection to a source or database.

This explains the basic process of what happens when you refresh data connected to an external data source:

  1. Someone starts refreshing the workbook’s connections to get up-to-date data.

  2. Connections are made to external data sources that are used in the workbook.

    Note: There are a variety of data sources you can access, such as OLAP, SQL Server, OLEDB providers, and ODBC drivers.

  3. The data in the workbook is updated.

The basic process of refreshing external data

If you are viewing a workbook in a browser window, and you want to refresh the data, you can typically do this in one of two modes: view mode or edit mode.

View mode

When you refresh a workbook in view mode, you simply update the data displayed in the workbook. You can do this in a browser window or in Excel, in read-only (not edit) mode.

In this case, the workbook is not tracked as a changed file. This means that in the location where the workbook is stored, your user credentials are not displayed as someone who recently edited the workbook.

Edit mode

When you refresh a workbook in edit mode, you open the workbook for editing (either in a browser window or in Excel). The workbook is tracked as a changed file. This means that your user credentials are displayed as someone who recently edited the workbook.

If you’re editing a workbook and you refresh the data, your changes are automatically saved after the data refresh has occurred. Anyone who has permissions to view the workbook will see your changes as soon as the workbook is saved.

You must use Excel to define external data connections for a workbook. You cannot define such settings while viewing a workbook in a browser window. The settings that you specify by using Excel are preserved when you publish a workbook to a SharePoint library.

To specify data refresh options, choose the Properties button for a particular data connection in Excel. The following table provides a brief description of various data refresh options that you can select.

  • Refresh every __ minutes — This option causes the workbook to attempt to refresh data at intervals of time that you specify (in minutes.)

  • Refresh data when opening the file — This option causes the workbook to attempt to refresh data automatically when the workbook is opened.

  • Refresh this connection on Refresh All — When selected, this option refreshes the data when you or other users click the Refresh All button.

    When unselected, this option prevents this connection from refreshing data when you or others click the Refresh All button. This is useful when you want to avoid data refresh errors, such as timeout errors for a particular connection in Excel Services.

Depending on how your environment is configured, data refresh might not occur. For example, if someone created a workbook that uses secure, external data connections to on-premises servers, those data connections will probably not work in Microsoft 365. If you run into a situation where you can’t refresh the data in a browser window, try opening the workbook in Excel.

You can also contact a SharePoint administrator.

For most connections, click any cell in the range or table that uses the connection, and then do one of the following:

  • Update only the selected data   Press ALT+F5, or on the Data tab, in the Connections group, click the arrow under Refresh All, and then click Refresh.

    Mouse pointing to the Refresh command on the ribbon

  • Update all data in the workbook   Press CTRL+ALT+F5, or on the Data tab, in the Connections group, click Refresh All.

    Mouse pointer over the Refresh All button

  • Control how or when the connection is refreshed   On the Data tab, in the Connections group, click the arrow under Refresh All, and then click Connection Properties.

    Mouse pointing to the Connection properties command on the ribbon

    In the dialog box that opens, choose the options you want on the Usage tab, under Refresh Control.

Some refresh operations require more steps, as detailed in the following sections. If you see your data source listed, review the corresponding section.

You can refresh an external data range automatically when you open the workbook. Optionally, you can save the workbook without saving the external data to shrink the size of the file.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

  1. Click the Usage tab.

  2. Under Refresh control, select the Refresh data when opening the file check box.

  3. If you want to save the workbook with the query definition but without the external data, select the Remove data from the external data range before saving the workbook check box.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

  3. Click the Usage tab.

  4. Select the Refresh every check box, and then enter the number of minutes between each refresh operation.

Stored passwords aren’t encrypted, so they’re not recommended. If your data source needs a password to connect to it, you can require that users enter the password before they can refresh the external data range. The following procedure doesn’t apply to data retrieved from a text file (.txt) or a Web query (.iqy).

Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don’t mix these elements. For example, Strong password: Y6dh!et5. Weak password: House27. Passwords should be 8 or more characters in length. A pass phrase that uses 14 or more characters is better.

It’s critical that you remember your password. If you forget your password, Microsoft cannot retrieve it. Store the passwords that you write down in a secure place away from the information that they help protect.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

  3. Click the Definition tab, and then clear the Save password check box.

Note: Excel prompts you 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’ll be prompted for the password again if you open the workbook that contains the query and then attempt a refresh operation.

For very large data sets, consider running a background refresh. This returns control of Excel to you instead of making you wait several minutes or more for the refresh to finish.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

    Note: You can’t run an OLAP query in the background.

    Note: You can’t run a query for any connection type that retrieves data for the Data Model.

  3. Click the Usage tab.

  4. Select the Enable background refresh check box to run the query in the background. Clear this check box to run the query while you wait.

    While you record a macro that includes a query, Excel doesn’t run the query in the background. To change the recorded macro so that the query runs in the background, edit the macro in the Visual Basic Editor. Change the refresh method for the QueryTable object from BackgroundQuery := False to BackgroundQuery := True.

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. To check on the refresh, or to cancel it, do one of the following:

  • Check the status of a query    A message appears on the Excel status bar to indicate that the query is running. Double-click the message to check the status of the query.

  • Stop a background refresh    To stop a query that’s running in the background, double-click the query status message on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.

  • Stop a query    To stop a query from running when background refresh is turned off, press the Esc key.

If you used Get & Transform to query a text file, no further steps are needed. If you imported the text file, the steps to refresh are as follows:

  1. Click any cell in the range or table that contains the link to the imported text file.

  2. On the Data tab, in the Connections group, click Refresh All.

    Mouse pointing to the Refresh command on the ribbon

    To update only the selected data, click Refresh.

    You can also right-click a cell in the range or table, and then click Refresh.

  3. In the Import Text File dialog box, browse to your text file, and then click Import.

Refreshing an offline cube file, which recreates the file by using the most recent data from the server cube, can be time consuming and require a lot of temporary disk space. Start the process at a time when you don’t need immediate access to other files in Excel, and make sure you have adequate disk space to save the file again.

  1. Click the PivotTable connected to the offline cube file.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Refresh.

    Mouse pointing to the Refresh command on the ribbon

  1. On the worksheet, click a mapped cell to select the XML map that you want to refresh.

  2. If the Developer tab isn’t available, do the following to display it:

    1. Click File, click Options, and then click Customize Ribbon.

    2. Under Main Tabs, select the Developer check box, and then click OK.

  3. On the Developer tab, in the XML group, click Refresh Data.

    XML Refresh Data

  • On the Data tab, in the Connections group, click Refresh All.

If you have multiple connections, and you only want to update a certain one, select any cell within that data range, click the arrow next to Refresh All, and click Refresh.

Mouse pointing to the Refresh command on the ribbon

Control how or when the connection is refreshed

  1. Click any cell that contains your connected data.

  2. On the Data tab, in the Connections group, click the arrow next to Refresh All, and click Connection Properties.

    Connection Properties

  3. On the Usage tab, set any options you want to change.

    For very large data sets, consider checking the Enable background refresh option. This returns control of Excel to you as soon as the refresh begins, instead of making you wait for the refresh to finish.

Cancel or check the status of a refresh

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. To check on the refresh, or to cancel it, do one of the following:

  • Check the status of a query    A message appears on the Excel status bar to indicate that the query is running. Double-click the message to check the status of the query.

  • Stop a background refresh    To stop a query that’s running in the background, double-click the query status message on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.

  • Stop a query    To stop a query from running when background refresh is turned off, press the Esc key.

When you use the Power Pivot add-in to refresh previously imported data, you can see whether refresh succeeds, fails, or is cancelled.

In Power Pivot, click Home > Get External Data > Refresh or Refresh All to re-import the current table or all of the tables in the data model.

Status of the refresh is indicated for each connection used in the data model. There are three possible outcomes.

Data refresh status messages in Power Pivot

“Success” reports on the number of rows imported into each table.

“Error” can occur if the database is offline, you no longer have permissions, or a table or column is deleted or renamed in the source. Verify the database is available, perhaps by creating a new connection in a different workbook.

“Cancelled” means that Excel did not issue the refresh request, probably because refresh is disabled on the connection.

Tip: Are you sharing this workbook with other people who might want to refresh data? Help your colleagues avoid data refresh errors by reminding them to request permissions on the data sources providing the data.

Table properties show queries used in data refresh

Data refresh is simply rerunning the same query that was used to get the data in the first place. You can view, and sometimes modify, the query by viewing table properties in the Power Pivot window.

  1. To view the query used during data refresh, click Power Pivot > Manage to open the Power Pivot window.

  2. Click Design > Table Properties.

  3. Switch to Query Editor to view the underlying query.

Queries are not visible for every type of data source. For example, queries are not shown for data feed imports.

Connection properties that cancel data refresh

In Excel, you can set connection properties that determine the frequency of data refresh. If refresh is not allowed on a particular connection, you’ll get a cancellation notice when you run Refresh All or attempt to refresh a specific table that uses the connection.

  1. To view connection properties, in Excel, click Data > Connections to view a list of all connections used in the workbook.

  2. Select a connection and click Properties.

  3. In Usage, under Refresh control, if the checkbox is cleared for Refresh this connection on Refresh All, you will get a cancellation when you try Refresh All in the Power Pivot window.

Refresh data on SharePoint Server 2013 or later

On SharePoint Server, you can schedule unattended data refresh on the server, but doing so requires that Power Pivot for SharePoint 2013 is installed and configured in your SharePoint environment. Check with your SharePoint administrator to find out if scheduled data refresh is available.

With the Power Query Editor, you can refresh a query to import the latest data into a table without having to recreate the query.

To refresh a query:

  1. Click Get & Transform > Show Queries.

  2. In the Workbook Queries pane, select the query you want to refresh.

  3. In the Power Query Editor ribbon, click Home > Query > Refresh preview.

Query Editor ribbon

When the data you use for your map changes, you can refresh it manually in 3D Maps. The changes will then be reflected on your map. Here’s how:

  • In 3D Maps, click Home > Refresh Data.

Refresh Data on the Home tab

Add data to Power Map

To add new data to your 3D MapsPower Map:

  1. In 3D Maps, go to the map you want to add data to.

  2. Leaving the 3D Maps window open, click in Excel and select the worksheet data you want to add.

  3. On the Excel ribbon, click Insert > Map arrow > Add Selected Data to Power Map.

Add Selected Data to Power Map command

Your 3D Maps will automatically update to show the additional data.

Data in a Microsoft Office Excel workbook that has been displayed in Excel Services can come from two different locations. The data may be stored directly in the workbook, or it may be stored in an external data source, such as in a database or in an Online Analytical Processing (OLAP) cube.

If the data comes from an external data source, the workbook author or administrator has defined the connection information, often in an Office data connection (.odc) file, which describes how to locate, log in, query, and access the external data source.

When you are connected to an external data source, you can perform a refresh operation to retrieve the updated data. Each time that you refresh data, you see the most recent version of the data, including any changes that were made to the data since it was last refreshed.

Learn about refreshing data

The following illustration explains the basic process of what happens when you refresh data connected to an external data source.

The basic process of refreshing external data

  1. A refresh operation gets up-to-date data.

  2. A connection, often saved to a connection file, defines all the information needed to access and retrieve data from an external data source.

  3. There are a variety of data sources you can access, such as OLAP, SQL Server, OLEDB providers, and ODBC drivers.

  4. Up-to-date data is added to the current workbook.

Learn about security concerns

When you are connected to an external data source and you attempt to refresh the data, it’s important to be aware of potential security issues, and to know what you can do about any security issues.

A data connection file often contains one or more queries that are used to refresh external data. By replacing this file, a user who has malicious intent can design a query to access confidential information and distribute it to other users or perform other harmful actions. Therefore, it’s important to ensure that the connection file was authored by a reliable individual, and the connection file is secure and comes from a trusted Data Connection Library (DCL).

For more information on how an administrator can author connection files, create trusted locations, and secure connection files, see Microsoft Office Excel Help and Office SharePoint Server Central Administration Help.

Note: Accessing an external data source usually requires credentials (such as a user name and a password) that are used to authenticate the user. Make sure that these credentials are provided to you in a safe and secure manner, and that you do not inadvertently reveal these credentials to others.

Control how data is refreshed

You can control how to refresh data from an external data source by doing one or more of the following:

  • Refresh on open   In Excel, a workbook author can create a workbook that automatically refreshes external data when the workbook is opened by selecting the Refresh data when opening the file check box in the Connection Properties dialog box. (On the Data tab, in the Connections group, click Connections, select the connection, click Properties, click the Usage tab, and then click Refresh data when opening the file.) In this case, Excel Services always refreshes the data before it displays a workbook and creates a new session. If the workbook author clears the Refresh data when opening the file check box, the data that is cached with the workbook is displayed, which means that when a user manually refreshes the data, the user sees refreshed, up-to-date data during the current session, but the data is not saved to the workbook. If you want to ensure that up-to-date data is always displayed when you display the workbook in Excel Services, select the Refresh data when opening the file check box by using Office Excel.

    If you are using an Office Data Connection file (.odc), make sure you also set the Always use connection file check box in the Connection Properties dialog box (On the Data tab, in the Connections group, click Connections, select the connection, click Properties, click the Definition tab, and then click Always use connection file).

    The trusted file location site settings, Short Session Timeout and External Data Cache Lifetime, can also have an impact on refresh operations. For more information, see your administrator or the Microsoft Office SharePoint Server Central Administration Help system.

  • Manual refresh   

    Note: You can manually refresh only a PivotTable report.

    1. Select a cell in a PivotTable report.

    2. On the Excel Web Access toolbar, under the Update menu, click Refresh Selected Connection.

      Notes: 

      • Any interactive operation that causes a requery of an OLAP data source initiates a manual refresh operation.

      • If this Refresh command is not visible, then the Web Part author has cleared the Refresh Selected Connection, Refresh All Connections property. For more information, see Excel Web Access Web Part custom properties.

  • Refresh all connections   On the Excel Web Access toolbar, under the Update menu, click Refresh All Connections.

  • Periodic refresh   By using Excel, the workbook author can specify that data automatically refreshes at a specified interval after the workbook is opened for each connection in the workbook. For example, an inventory database may be updated every hour, and so the workbook author has defined the workbook to automatically refresh every 60 minutes.

    A Web Part author can select or clear the Allow Excel Web Access Periodic Data Refresh property to enable or disable this periodic refresh operation, if the property has been defined by the workbook author. When the time interval elapses, by default, the following refresh alert prompt is displayed at the bottom of the Excel Web Access Web Part:

    Refresh data for <List of Connections>? (Now) (Always) (Don’t ask me again)

    An Excel Web Access Web Part author can also set the Display Periodic Data Refresh Prompt property to control the behavior of the message that is displayed when Excel Services performs a periodic data refresh during a session:

    • Always      means that the message is displayed with a prompt at each interval.

    • Optionally      means that a user can choose to continue periodic refresh without displaying a message.

    • Never      means that Excel Web Access performs a periodic refresh without displaying a message or prompt.

    For more information, see Excel Web Access Web Part custom properties.

  • Cancel a refresh   Because a refresh operation may take longer than you expect, you can cancel it. While the refresh operation occurs, Excel Services displays a message with a prompt. Click Cancel to interrupt the operation, so that you can complete the refresh operation at a more convenient time. Data returned by queries before you cancelled the refresh operation will display.

  1. Click any cell in the range or table that contains the link to the external data.

  2. On the Data tab, in the Connections group, click Refresh All.

    Refresh Data Connection

    To update only the selected data, click Refresh.

    You can also right-click a cell in the range or table, and then click Refresh.

    Note: If you have more than one workbook open, you’ll need to repeat the operation in each workbook.

  1. Click any cell in the range or table that contains the link to the imported text file.

  2. On the Data tab, in the Connections group, click Refresh All.

    Refresh Data Connection

    To update only the selected data, click Refresh.

    You can also right-click a cell in the range or table, and then click Refresh.

  3. In the Import Text File dialog box, browse to your text file, and then click Import.

Refreshing an offline cube file, which recreates the file by using the most recent data from the server cube, can be time consuming and require a lot of temporary disk space. Start the process at a time when you don’t need immediate access to other files in Excel, and make sure you have adequate disk space to save the file again.

  1. Click the PivotTable connected to the offline cube file.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Refresh.

    Refresh Data Connection

  1. On the worksheet, click a mapped cell to select the XML map that you want to refresh.

  2. If the Developer tab isn’t available, do the following to display it:

    1. Click File, click Options, and then click Customize Ribbon.

    2. Under Main Tabs, select the Developer check box, and then click OK.

  3. On the Developer tab, in the XML group, click Refresh Data.

    XML Refresh Data

  • On the Data tab, click Refresh All.

If you have multiple connections, and you only want to update a certain one, select any cell within that data range, click the arrow next to Refresh All, and click Refresh.

Refresh Data Connection

Control how or when the connection is refreshed

  1. Click any cell that contains your connected data.

  2. On the Data tab, click the arrow next to Refresh All, and click Connection Properties.

    Connection Properties

  3. On the Usage tab, set any options you want to change.

    For very large data sets, consider checking the Enable background refresh option. This returns control of Excel to you, instead of making you wait for the refresh to finish.

Cancel or check the status of a refresh

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. To check on the refresh, or to cancel it, do one of the following:

  • Check the status of a query    A message appears on the Excel status bar to indicate that the query is running. Double-click the message to check the status of the query.

  • Stop a background refresh    To stop a query that’s running in the background, double-click the query status message on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.

  • Stop a query    To stop a query from running when background refresh is turned off, press the Esc key.

When you use the Power Pivot add-in to refresh previously imported data, you can see whether refresh succeeds, fails, or is cancelled.

  • In Power Pivot, click Home > Get External Data > Refresh or Refresh All to re-import the current table or all of the tables in the data model.

    Status of the refresh is indicated for each connection used in the data model. There are three possible outcomes.

    Data refresh status messages in Power Pivot

“Success” reports on the number of rows imported into each table.

“Error” can occur if the database is offline, you no longer have permissions, or a table or column is deleted or renamed in the source. Verify the database is available, perhaps by creating a new connection in a different workbook.

“Cancelled” means that Excel did not issue the refresh request, probably because refresh is disabled on the connection.

Tip: Are you sharing this workbook with other people who might want to refresh data? Help your colleagues avoid data refresh errors by reminding them to request permissions on the data sources providing the data.

Table properties show queries used in data refresh

Data refresh is simply rerunning the same query that was used to get the data in the first place. You can view, and sometimes modify, the query by viewing table properties in the Power Pivot window.

  1. To view the query used during data refresh, click Power Pivot > Manage to open the Power Pivot window.

  2. Click Design > Table Properties.

  3. Switch to Query Editor to view the underlying query.

Queries are not visible for every type of data source. For example, queries are not shown for data feed imports.

Connection properties that cancel data refresh

In Excel, you can set connection properties that determine the frequency of data refresh. If refresh is not allowed on a particular connection, you’ll get a cancellation notice when you run Refresh All or attempt to refresh a specific table that uses the connection.

  1. To view connection properties, in Excel, click Data > Connections to view a list of all connections used in the workbook.

  2. Select a connection and click Properties.

  3. In Usage, under Refresh control, if the checkbox is cleared for Refresh this connection on Refresh All, you will get a cancellation when you try Refresh All in the Power Pivot window.

Refresh data on SharePoint Server 2013

On SharePoint Server 2013, you can schedule unattended data refresh on the server, but doing so requires that Power Pivot for SharePoint 2013 is installed and configured in your SharePoint environment. Check with your SharePoint administrator to find out if scheduled data refresh is available.

With Power Query, you can refresh a query to import the latest data into a table without having to recreate the query.

Important: 

  • Excel 2010   Power Query is not included in Excel 2010, but you can download, install, and activate the Power Query Add-In.

  • To activate the Power Query add-in, click File > Options > Add-Ins. In the Manage section at the bottom, choose the COM Add-ins option from the drop-down list, then click Go. Click the Power Query check box, then OK. The Power Query ribbon should appear automatically, but if it doesn’t, close and restart Excel.

To refresh a query:

  1. In the Query Editor ribbon, click Refresh preview.

Query Editor ribbon

Note: The Query Editor only appears when you load, edit, or create a new query using Power Query. The following video shows the Query Editor window appearing after editing a query from an Excel workbook. To view the Query Editor without loading or editing an existing workbook query, from the Get External Data section in the Power Query ribbon tab, select From Other Sources > Blank Query. The following video shows one way to display the Query Editor.

How to see Query Editor in Excel

If your Excel workbook has a connection to a table or query in an Access database, you can make sure it shows the most up to date information. Use the Refresh command (on the Data tab) to do this.

  1. On your worksheet, click any cell that contains your Access data.

  2. On the Data tab, in the Connections group, click the arrow next to Refresh All, and then click Refresh.

Refresh Data Connection

To control how or how often the connection is refreshed:

  1. Click any cell that contains your Access data.

  2. In the Connections group, click the arrow next to Refresh All, and click Connection Properties.

For very large data sets, consider running a background refresh. This returns control of Excel to you instead of making you wait several minutes or more for the refresh to finish.

Connection Properties

  1. On the Usage tab, set any options you want to change.

Check the status of or cancel a refresh

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. To check on the refresh, or to cancel it, do one or more of the following:

  • Check the status of a query    A message appears on the Excel status bar to indicate that the query is running. Double-click the message to check the status of the query.

  • Stop a background refresh    To stop a query that’s running in the background, double-click the query status message on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.

  • Stop a query    To stop a query from running when background refresh is turned off, press the Esc key.

If your Excel workbook has a connection to a table or query in a SQL Server database, you can make sure it shows the most up to date information. Use the Refresh command (on the Data tab) to do this.

  1. On your worksheet, click any cell that contains your SQL Server data.

  2. On the Data tab, in the Connections group, click the arrow next to Refresh All, and then click Refresh.

Refresh Data Connection

To control how or how often the connection is refreshed:

  1. Click any cell that contains your SQL Server data.

  2. In the Connections group, click the arrow next to Refresh All, and click Connection Properties.

For very large data sets, consider running a background refresh. This returns control of Excel to you instead of making you wait several minutes or more for the refresh to finish.

Connection Properties

  1. On the Usage tab, set any options you want to change, such as enabling a background refresh.

Cancel or check the status of a refresh

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. To check on the refresh, or to cancel it, do one of the following:

  • Check the status of a query    A message appears on the Excel status bar to indicate that the query is running. Double-click the message to check the status of the query.

  • Stop a background refresh    To stop a query that’s running in the background, double-click the query status message on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.

  • Stop a query    To stop a query from running when background refresh is turned off, press the Esc key.

If your Excel workbook has a connection to a table or query in an OLE DB data source, you can make sure it shows the most up to date information. Use the Refresh command (on the Data tab) to do this.

  1. On your worksheet, click any cell that contains your OLE DB data.

  2. On the Data tab, in the Connections group, click the arrow next to Refresh All, and then click Refresh.

Refresh Data Connection

To control how or how often the connection is refreshed:

  1. Click any cell that contains your OLE DB data.

  2. In the Connections group, click the arrow next to Refresh All, and click Connection Properties.

For very large data sets, consider running a background refresh. This returns control of Excel to you instead of making you wait several minutes or more for the refresh to finish.

Connection Properties

  1. On the Usage tab, set any options you want to change.

Check or cancel a refresh

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. To check on or cancel a refresh, do one of the following:

  • Check the status of a query    A message appears on the Excel status bar to indicate that the query is running. Double-click the message to check the status of the query.

  • Stop a background refresh    To stop a query that’s running in the background, double-click the query status message on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.

  • Stop a query    To stop a query from running when background refresh is turned off, press the Esc key.

When the data you use for your map changes, you can refresh it manually in 3D Maps. The changes will then be reflected on your map. Here’s how:

  • In 3D Maps, click Home > Refresh Data.

Refresh Data on the Home tab

Add data to Power Map

To add new data to your 3D MapsPower Map:

  1. In 3D Maps, go to the map you want to add data to.

  2. Leaving the 3D Maps window open, click in Excel and select the worksheet data you want to add.

  3. On the Excel ribbon, click Insert > Map arrow > Add Selected Data to Power Map.

Add Selected Data to Power Map command

Your 3D Maps will automatically update to show the additional data.

Manually refresh

  1. Click anywhere in the PivotTable.

    This displays the PivotTable Tools, adding an Options and a Design tab.

  2. On the Options tab, in the Data group, do one of the following:

  3. To update the information to match the data source, click the Refresh button, or press ALT+F5.

    You can also right-click the PivotTable, and then click Refresh.

  4. To refresh all PivotTables in the workbook, click the Refresh button arrow, and then click Refresh All.

    Excel Ribbon Image

    If refreshing takes longer than you expect, click Options > Refresh > Refresh Status to check the refresh status.

    To stop refreshing, click Cancel Refresh.

Prevent column widths and cell formatting from adjusting

If the column widths and cell formatting of your data adjust when you refresh the PivotTable data, and you don’t want that to happen, make sure the following options are checked:

  1. Click Options > Options.

    PivotTable group on the Options tab under PivotTable Tools

  2. On the Layout & Format tab, check the Autofit column widths on update and Preserve cell formatting on update boxes.

Refresh PivotTable data automatically when opening the workbook

  1. Click anywhere in the PivotTable.

  2. On the Options tab, in the PivotTable group, click Options.

    PivotTable group on the Options tab under PivotTable Tools

  3. In the PivotTable Options dialog box, on the Data tab, select the Refresh data when opening the file check box.

Data in a Microsoft Office Excel workbook that has been displayed in Excel Services can come from two different locations. The data may be stored directly in the workbook, or it may be stored in an external data source, such as in a database or in an Online Analytical Processing (OLAP) cube.

If the data comes from an external data source, the workbook author or administrator has defined the connection information, often in an Office data connection (.odc) file, which describes how to locate, log in, query, and access the external data source.

When you are connected to an external data source, you can perform a refresh operation to retrieve the updated data. Each time that you refresh data, you see the most recent version of the data, including any changes that were made to the data since it was last refreshed.

Learn about refreshing data

The following illustration explains the basic process of what happens when you refresh data connected to an external data source.

The basic process of refreshing external data

  1. A refresh operation gets up-to-date data.

  2. A connection, often saved to a connection file, defines all the information needed to access and retrieve data from an external data source.

  3. There are a variety of data sources you can access, such as OLAP, SQL Server, OLEDB providers, and ODBC drivers.

  4. Up-to-date data is added to the current workbook.

Learn about security concerns

When you are connected to an external data source and you attempt to refresh the data, it’s important to be aware of potential security issues, and to know what you can do about any security issues.

A data connection file often contains one or more queries that are used to refresh external data. By replacing this file, a user who has malicious intent can design a query to access confidential information and distribute it to other users or perform other harmful actions. Therefore, it’s important to ensure that the connection file was authored by a reliable individual, and the connection file is secure and comes from a trusted Data Connection Library (DCL).

For more information on how an administrator can author connection files, create trusted locations, and secure connection files, see Microsoft Office Excel 2007 Help and Office SharePoint Server Central Administration Help.

Security Note: Accessing an external data source usually requires credentials (such as a user name and a password) that are used to authenticate the user. Make sure that these credentials are provided to you in a safe and secure manner, and that you do not inadvertently reveal these credentials to others.

Control how data is refreshed

You can control how to refresh data from an external data source by doing one or more of the following:

  • Refresh on open   In Microsoft Office Excel 2007, a workbook author can create a workbook that automatically refreshes external data when the workbook is opened by selecting the Refresh data when opening the file check box in the Connection Properties dialog box. (On the Data tab, in the Connections group, click Connections, select the connection, click Properties, click the Usage tab, and then click Refresh data when opening the file.) In this case, Excel Services always refreshes the data before it displays a workbook and creates a new session. If the workbook author clears the Refresh data when opening the file check box, the data that is cached with the workbook is displayed, which means that when a user manually refreshes the data, the user sees refreshed, up-to-date data during the current session, but the data is not saved to the workbook. If you want to ensure that up-to-date data is always displayed when you display the workbook in Excel Services, select the Refresh data when opening the file check box by using Office Excel.

    If you are using an Office Data Connection file (.odc), make sure you also set the Always use connection file check box in the Connection Properties dialog box (On the Data tab, in the Connections group, click Connections, select the connection, click Properties, click the Definition tab, and then click Always use connection file).

    The trusted file location site settings, Short Session Timeout and External Data Cache Lifetime, can also have an impact on refresh operations. For more information, see your administrator or the Microsoft Office SharePoint Server Central Administration Help system.

  • Manual refresh   

    Note: You can manually refresh only a PivotTable report.

    1. Select a cell in a PivotTable report.

    2. On the Excel Web Access toolbar, under the Update menu, click Refresh Selected Connection.

      Notes: 

      • Any interactive operation that causes a requery of an OLAP data source initiates a manual refresh operation.

      • If this Refresh command is not visible, then the Web Part author has cleared the Refresh Selected Connection, Refresh All Connections property. For more information, see Excel Web Access Web Part custom properties.

  • Refresh all connections   On the Excel Web Access toolbar, under the Update menu, click Refresh All Connections.

  • Periodic refresh   By using Office Excel 2007, the workbook author can specify that data automatically refreshes at a specified interval after the workbook is opened for each connection in the workbook. For example, an inventory database may be updated every hour, and so the workbook author has defined the workbook to automatically refresh every 60 minutes.

    A Web Part author can select or clear the Allow Excel Web Access Periodic Data Refresh property to enable or disable this periodic refresh operation, if the property has been defined by the workbook author. When the time interval elapses, by default, the following refresh alert prompt is displayed at the bottom of the Excel Web Access Web Part:

    Refresh data for <List of Connections>? (Now) (Always) (Don’t ask me again)

    An Excel Web Access Web Part author can also set the Display Periodic Data Refresh Prompt property to control the behavior of the message that is displayed when Excel Services performs a periodic data refresh during a session:

    • Always      means that the message is displayed with a prompt at each interval.

    • Optionally      means that a user can choose to continue periodic refresh without displaying a message.

    • Never      means that Excel Web Access performs a periodic refresh without displaying a message or prompt.

    For more information, see Excel Web Access Web Part custom properties.

  • Cancel a refresh   Because a refresh operation may take longer than you expect, you can cancel it. While the refresh operation occurs, Excel Services displays a message with a prompt. Click Cancel to interrupt the operation, so that you can complete the refresh operation at a more convenient time. Data returned by queries before you cancelled the refresh operation will display.

You can refresh an external data range automatically when you open the workbook. Optionally, you can save the workbook without saving the external data to shrink the size of the file.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

  1. Click the Usage tab.

  2. Under Refresh control, select the Refresh data when opening the file check box.

  3. If you want to save the workbook with the query definition but without the external data, select the Remove data from the external data range before saving the workbook check box.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

  3. Click the Usage tab.

  4. Select the Refresh every check box, and then enter the number of minutes between each refresh operation.

Stored passwords aren’t encrypted, so they’re not recommended. If your data source needs a password to connect to it, you can require that users enter the password before they can refresh the external data range. The following procedure doesn’t apply to data retrieved from a text file (.txt) or a Web query (.iqy).

Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords don’t mix these elements. For example, Strong password: Y6dh!et5. Weak password: House27. Passwords should be 8 or more characters in length. A pass phrase that uses 14 or more characters is better.

It’s critical that you remember your password. If you forget your password, Microsoft cannot retrieve it. Store the passwords that you write down in a secure place away from the information that they help protect.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

  3. Click the Definition tab, and then clear the Save password check box.

Note: Excel prompts you 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’ll be prompted for the password again if you open the workbook that contains the query and then attempt a refresh operation.

For very large data sets, consider running a background refresh. This returns control of Excel to you instead of making you wait several minutes or more for the refresh to finish.

  1. Click a cell in the external data range.

  2. On the Data tab, in the Connections group, click Refresh All, and then click Connection Properties.

    Connection Properties

    Note: You can’t run an OLAP query in the background.

    Note: You can’t run a query for any connection type that retrieves data for the Data Model.

  3. Click the Usage tab.

  4. Select the Enable background refresh check box to run the query in the background. Clear this check box to run the query while you wait.

    While you record a macro that includes a query, Excel doesn’t run the query in the background. To change the recorded macro so that the query runs in the background, edit the macro in the Visual Basic Editor. Change the refresh method for the QueryTable object from BackgroundQuery := False to BackgroundQuery := True.

If your workbook is connected to a large data source, refreshing it might take a little longer than you expect. To check on the refresh, or to cancel it, do one of the following:

  • Check the status of a query    A message appears on the Excel status bar to indicate that the query is running. Double-click the message to check the status of the query.

  • Stop a background refresh    To stop a query that’s running in the background, double-click the query status message on the status bar to display the External Data Refresh Status dialog box, and then click Stop Refresh.

  • Stop a query    To stop a query from running when background refresh is turned off, press the Esc key.

See Also

Power Query for Excel Help

Refresh external data in a workbook in SharePoint Server

Change formula recalculation, iteration, or precision in Excel

Block or unblock external content in Office documents

  • Remove From My Forums
  • Question

  • Hi,

    We are facing excel connection refreshing issue in excel online.

    We have 2 files in a SharePoint library, let’s say file A (updates everyday) and file B. B is a Pivoting file and reads the data from A through connection, in connection properties we have mentioned refresh on opening the file.

    The issue is when we are opening the file B in excel online, the connection is not getting refreshed and getting the below error. 

    Error:

    We were unable to refresh one or more data connections in this workbook.

    Regards,

    Sudheer


    Thanks & Regards, Sudheer

Answers

    • Proposed as answer by

      Tuesday, November 21, 2017 2:07 AM

    • Marked as answer by
      Sudheer Madduru
      Tuesday, November 21, 2017 3:58 AM

Solved! See below for solution!

I’m in Excel 2010 connecting to multiple, seperate Access 2010 db’s from Excel through PivotTable data connections.

Refreshing all my connections causes the final refresh to fail. The order does not matter, I’ve manually refreshed in different orders, same error.

However, if I save and close after refreshing a few, then come back and refresh the last one, there is no problem at all.

Leads me to believe that I’m hitting some sort of memory cap that is reset when I save and close.

Can I re-create that effect through VBA without actually save/closing? Is there a better solution to this issue?

Error Messages — These three pop up in this order:

  • The query did not run, or the database table could not be opened.
  • Problems obtaining data.
  • A PivotTable, cube function or slicer using connection has failed to refresh.

Current Code

Private Sub CommandButton1_Click()
On Error GoTo ErrHndlr

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.StatusBar = "Refreshing Data - Please Be Patient"

ActiveWorkbook.Connections("Connection_1").Refresh
ActiveWorkbook.Connections("Connection_2").Refresh
ActiveWorkbook.Connections("Connection_3").Refresh

Application.Calculation = xlCalculationAutomatic
Application.StatusBar = "Ready"
[LastUpdated].Value = FormatDateTime(Now, vbGeneralDate)
Application.ScreenUpdating = True
Exit Sub

ErrHndlr:
  Application.StatusBar = "Ready"
  Application.Calculation = xlCalculationAutomatic
  Application.ScreenUpdating = True
  [LastUpdated].Value = "Update Error"
  Exit Sub

End Sub

Connection String

Provider=Microsoft.ACE.OLEDB.12.0
;User ID=Admin
;Data Source=C:FoldersDatabase_1.accdb
;Mode=Share Deny None
;Extended Properties=""
;Jet OLEDB:System database=""
;Jet OLEDB:Registry Path=""
;Jet OLEDB:Engine Type=6
;Jet OLEDB:Database Locking Mode=0
;Jet OLEDB:Global Partial Bulk Ops=2
;Jet OLEDB:Global Bulk Transactions=1
;Jet OLEDB:New Database Password=""
;Jet OLEDB:Create System Database=False
;Jet OLEDB:Encrypt Database=False
;Jet OLEDB:Don't Copy Locale on Compact=False
;Jet OLEDB:Compact Without Replica Repair=False
;Jet OLEDB:SFP=False
;Jet OLEDB:Support Complex Data=False
;Jet OLEDB:Bypass UserInfo Validation=False

Attempted Solutions

  • Disable Background Refresh — Already disabled
  • Disable Auto-Recover (to save memory)
  • Clear «Undo Stack» (to save memory)
  • ‘DoEvents’ to delay code execution until each refresh is concluded, changing:

this

ActiveWorkbook.Connections("Connection_1").Refresh

to

With ActiveWorkbook.Connections("Connection_1")
  Select Case .Type
    Case xlConnectionTypeODBC
      With .ODBCConnection
        .Refresh
        Do While .Refreshing
          DoEvents
        Loop
      End With
    Case xlConnectionTypeOLEDB
      With .OLEDBConnection
        .Refresh
        Do While .Refreshing
          DoEvents
        Loop
      End With
    Case Else
      .Refresh
  End Select
End With

SOLUTION!

Side note, I have a couple extra connections that I didn’t want updated through this code, and added some additional, simple logic to specify which connections I wanted updated. This code here works to refresh every connection in your workbook:

Dim i As Integer
Dim awc As WorkbookConnection
Dim c As OLEDBConnection

Set awc = ActiveWorkbook.Connections.Item(i)
Set c = awc.OLEDBConnection
c.EnableRefresh = True
c.BackgroundQuery = False
c.Reconnect
c.Refresh
awc.Refresh
c.MaintainConnection = False
Next i

I don’t know the specifics of why this works, which part of this allows Excel to get over its self-limitation. I’d love to hear more if anyone is more familiar!

There are two ways to make Excel automatically refresh data connections and recalculate a worksheet.  These tricks are important with the Stock and Currency data type in Excel 365 but also other situations.

Normally Excel will update itself when you change a cell value.  These days there are situations where cells change value but Excel does NOT update the worksheet.  In other words, modern Excel has changed in ways that Microsoft hasn’t yet fully adapted to.

Ideally, Excel would have an overall setting to refresh the worksheet every ‘n’ seconds or minutes.  In 2022, Microsoft finally added some Stock/Currency auto-refresh options but they are incomplete and limited.

This article has TWO different ways to force updates in Excel. One is a ‘traditional’ macro approach, the other is a newer trick using PowerQuery in conjunction with single macro.

Either option gives you more control over updating than Microsoft’s simplistic ‘tick the box’ addition to Excel 365.

Stock Data Type

With the Stock Data Type  the ability to update automatically is more important.  Users will want their worksheets to grab the latest prices automatically, something the current preview releases can’t do.  Instead of having a nice automatic ‘ticker’, we’re expected to click ‘Refresh’ to get the latest prices.

The Stock, Currency and other linked data types are curious beasts. They are data connections to external sources but do NOT appear as Excel Data Connections.  That means you can’t setup an automatic data refresh, as you would with normal data connections.  In fact, there’s no exposed controls for the Stock, Currency or other linked data types.

NOW() and other volatile functions

The NOW() function updates to the latest date and time whenever Excel recalculates the worksheet. But if there’s nothing to make that happen, Now() doesn’t change value.  Some external factor is needed to make Excel update Now() and the rest of the worksheet.  In other words, you should be able to glance at a worksheet and know it’s up to the second but that’s not possible with Excel ‘out of the box’.

Microsoft calls NOW() and similar functions ‘volatile’ because their values can change even if no other cells have changed.  Other volatile functions are Today(), Randbetween(), Offset() and Indirect().  In some situations Info(), Cell() and SumIf() can also be volatile.

VBA custom functions can also be tagged as volatile using this line in the function code:

Application.Volatile

That line makes the function run anytime Excel updates/recalcs the worksheet.

The trick is to make an Excel macro which forces data connections to update then mark that function as Volatile so it will be run whenever the workbook is updating.

Maybe you want your worksheet to update automatically as a precaution?  Many old Excel hands remember situations where Excel hasn’t properly updated so they like the ‘belt and braces’ approach (at least occasionally).

Automatic update code

The standard method of forcing automatic update of Excel is a short snippet of VBA code. Here’s what we use, there are many variations on the same theme. The full code is at the bottom of the article.

There are three functions.

RefreshAllDataConn

does the actual refreshing of data connections ( Workbooks(ThisWorkbook.Name).RefreshAll ) and we added two, optional,  lines to display the last time refreshed on the bottom status bar.

If you wanted to be extra careful, add line to explicitly force recalculation.  Either  ActiveSheet.Calculate  or the extreme Application.CalculateFull (use sparingly, this would slow down a large worksheet).

AutoRefresh

run the RefreshAllDataConn sub every minute or whatever value you set on the line  Application.OnTime Now + TimeValue(“00:01:00”), “AutoRefresh”

Workbook_Open

an in-built Excel function that runs automatically when the worksheet is opened.  In this case it starts AutoRefresh.

PowerQuery data Connection workaround

The disadvantage of the VBA approach is that a .xlsm worksheet is necessary (macro enabled Excel worksheet).  There can be problems sharing macro enabled files because of security concerns.

The arrival of PowerQuery / Get and Transform means there’s another way to force a worksheet recalculation.  It’s a workaround and not perfect, but it’s possible and doesn’t need a macro-enabled worksheet.

In short, ensure that there’s a data query setup with auto-refresh.  If there isn’t a data connection, add a small one to the worksheet.

Once you have an auto-refreshing query, the worksheet including any volatile functions should also refresh.

Ideally the Stock and Geo data types should also refresh.

Any Excel data query comes with some refresh options in the Query properties.  Most of them default OFF.

Refresh every nnn minutes –  defaults off with 60 minutes suggested.

Refresh data when opening the file

Enable background refresh

Refresh this connection on Refresh All

The auto-refresh workaround is to create a small and practically insignificant data connection.  Then configure that data connection to update every minute or whatever time you wish.  That should force the worksheet to update including the volatile functions mentioned above.

Some versions of this workaround add a link to a tiny csv file on the same computer.  We’ve got the same result using a data connection from a table in the worksheet.

Create a small table with a single cell.  The cell can have anything but we create a cell with NOW() in it, for reasons we’ll explain later.

Select the table then choose Data | Get Data | From other sources | from Table/Range.  The exact menu item maybe different depending on your version of Excel.

When the Query Editor opens, just Close and Load it.  In the data connections pane, you’ll see a query.

Right-click the query, choose properties to see the settings we need.

Set the refresh rate that suits you.

To be tidy, we move the source table (right) onto the same sheet at the loaded query (left).  Because we used NOW() in the source table cell, it’ll be easy to see when/if the worksheet has refreshed.

VBA Code example

Sub RefreshAllDataConn()
    ' Refresh all Data Connections.

    ' This should include Stock and Currency data types, even though they aren't listed.

    Workbooks(ThisWorkbook.Name).RefreshAll

    ' Show update time on status bar to confirm.
    ' comment these lines out if not needed.

    Application.DisplayStatusBar = True

    Application.StatusBar = "Refreshed at: " & Now()

End Sub




Sub AutoRefresh()

' to run a Refresh All on the workbook every n minutes

   RefreshAllDataConn

   ' Repeat every minute or change to whatever value you prefer.

   Application.OnTime Now + TimeValue("00:01:00"), "AutoRefresh"


' this is a simple example. There's no coded way to exit this function.

End Sub

Private Sub Workbook_Open()

' Starts the automatic refresh when the workbook is opened,

' commented out as a precaution.

    ' AutoRefresh

End Sub

Excel’s Stock / Currency data (kinda, sorta) gets auto-refresh
Make automatic Excel worksheet list or table of contents

Complete Excel NetworkDays() solution with holidays & vacations

You all must have heard of Excel Workbook Connections but do know how to manage workbook connection in Excel? Well if you are not having any idea of enabling data connection in Excel workbook.

In that case our, this Excel workbook connections tutorial will help in grabbing every pinch of information reading this. So, that any Excel user can easily perform and manage external data connections in Excel.

What Is Data Connection In Excel?

What Is Data Connection In Excel?

Data of any Excel workbook can only be bring from different locations. Firstly, either the data is directly stored in your Excel workbook. Or secondly it may be saved in the external data source, like a database, an OLAP (Online Analytical Processing cube) or text file.

Using the data connection in Excel, external data sources are well connected with Excel workbook. Basically this data connection in Excel contains set of information about how to log in, query, locate, and perfectly access the external data source.

After connecting your excel workbook with external data source. One can easily use the refresh option to extract the updated data from their workbook. Using this way, user can get the most updated version of their data including the changes made in the data since it was last refreshed.

Well the Connection information can be stored in a connection file or in the workbook like Universal Data Connection (UDC) file (.udcx) or Office Data Connection (ODC) file (.odc)

These connection files are very useful to share connections on regular basis also to facilitate data source administration.

If you are using the connection file for connecting with the data source. Then in that case Excel will copies down the connection details from the connection file into your Excel workbook.

Different Ways To Perform Excel Workbook Connections

Different Ways To Perform Excel Workbook Connections

In this Excel workbook connections tutorial we will learn 3 different ways to use Data Connection In Excel 2010/2013/2016/2019:

  • Workbook Connections dialog box
  • Creating an Office Data Connection (ODC) file (.odc)
  • Refresh external data connection

Method 1: Excel Workbook Connections Using Workbook Connections Dialog Box

Excel Workbook Connections Using Workbook Connections Dialog Box

Excel Workbook Connections dialog box option helps in easy managing of single or multiple connections with the external data sources of your workbook. Apart from this the Workbook Connections dialog box is helpful to perform the following tasks:

  • It helps to edit, refresh, create and delete connections which are used in Excel workbook.
  • Show the location of each connection that is already been used in the current Excel workbook.
  • Easy diagnosis of error message regarding external data connections.
  • With this option, user can either redirect connection to different data or to the different server. Or alternatively user can easily replace the connection file with the existing connection.
  • It becomes too easy to make & share connection files.

Steps To Manage Excel Workbook Connection Using Workbook Connections Dialog Box

Here is how to manage connections in your current using Excel workbook i.e by using Workbook Connections dialog box:

Identify a connection

In the top portion of the dialog box, all connections in the workbook are displayed automatically with the following information:

Column Comment
Name  connection name is, defined within Connection Properties dialog box.
Description A short description about connection, is mentioned in Connection Properties dialog box.
Last refreshed when was the connection was last refreshed such as it’s date and time appears in this section. If it is blank, then it means that the connection has not refreshed yet.

Add a connection

  • Tap to the Add option to get the dialog box of Existing Connections.

Display Connection Information

  • For this you need to choose a connection from the opened Existing Connections dialog box.
  • Now hit the Properties option and this will open the dialog box of Connection Properties.

Refresh The External Data.

  • Hit the arrow option present next to the Refresh option. After then perform anyone of the following:
    • If you want to refresh any specific connections only, then make selections of those connections. After then tap to the Refresh option.
    • For refreshing all connections of your workbook, just clear off all the connections. After that tap to the Refresh All option.
    • If you want to get the status information about refresh operation then choose the connections about which you want to extract information. After then hit on the Refresh Status option.
    • For stopping down the current running refresh operation just tap to the Cancel Refresh option.

Remove One Or More Connections

  • Choose the connections which you wants to remove from your Excel workbook. After then tap to the Remove option.

Notes:

  • Well this option appears disabled to you if your workbook is protected one or if it is an object, like PivotTable report, which uses the protected connection.
  • Removing connection will only deletes off the connection. It will not remove any data or any object from your Excel workbook.

Important: By removing connection you are actually breaking the connection with the data source which may leads to cause unintentional consequences, Like different formula results or you may face difficulty in accessing Excel features.

Method 2: Excel Workbook Connections Using Refresh External Data Connection Option

Excel Workbook Connections Using Refresh External Data Connection Option

User can connect their Excel workbook with an external data source, like to another Excel workbook, SQL Server database or an OLAP cube.

Well this connection information gets displayed on your workbook as PivotTable report, PivotChart, table.

For keeping the data of your Excel workbook updated you can make use of “Refresh” option to link the data with its source.

So whenever you will refresh your connection, you will only get the most current updated data.

Step To Use Refresh External Data Connection Option

For connections just tap to any cell of your Excel table which uses the connection. After then perform any of the following operation:

  • Automatically refresh data when excel workbook is opened
  • Automatically refresh data at regular interval

Step To Automatically Refresh Data When Excel Workbook Is Opened

  • Tap to the cell present within the external data range.
  • Now on the Data tab, go to the Queries & Connections Hit the arrow key present within the Refresh All option, and from this tap to the Connection Properties.

refresh data when workbook opened---1

  • From the opened dialog box of Connection Properties dialog tap to the Usage tab, within Refresh control. After then choose the check box “Refresh data when opening the file”.
  • In order to save your workbook with the complete query definition excluding external data. You need to choose the check box “Remove data from the external data range before saving the workbook”.

Step To Automatically refresh data at regular interval:

  • Tap to the cell present within the external data range.
  • Now on the Data tab, go to the Queries & Connections Hit the arrow key present within the Refresh All option, and from this tap to the Connection Properties.

refresh data when workbook at regular interval---1

  • In the opened Connection Properties dialog box. Hit Usage tab option.
  • Choose the check box Refresh every. After then set the minute interval that will automatically refresh your data after certain period of time.

Method 3: Excel Workbook Connections By Creating An Office Data Connection (ODC) File

Excel Workbook Connections By Creating An Office Data Connection (ODC) File

By making use of the Data Connection Wizard or Connection Properties dialog box one can easily use their Excel worksheet to create an Office Data Connection (ODC) file (.odc).

  1. You can perform any of the following task:
    • Make new connection with data source. To catch more information, have a look at following topics :
      • Connect to SQL Server Analysis Services Database (Import)
      • Import or export text files
      • Move data from Excel to Access
  • Or you can just make use of the existing connection. For more information, see Connect to (Import) external data.
  1. After then save the connection detail into the connection file. For this, just make a tap to the Export Connection File option present on the Definition tab of Connection Properties dialog box. This will open the File Save dialog box, so save your current connection information into the ODC file.

Wrap Up:

Hopefully, all the above mentioned fixes to setup Excel Workbook Connections will help you in easy using of data connection in your respective Excel 2010/2013/2016/2019 application. Apart from this if you you have any other query to ask then, ask it in our comment section.

Priyanka is an entrepreneur & content marketing expert. She writes tech blogs and has expertise in MS Office, Excel, and other tech subjects. Her distinctive art of presenting tech information in the easy-to-understand language is very impressive. When not writing, she loves unplanned travels.

Понравилась статья? Поделить с друзьями:
  • Excel connect to postgresql
  • Excel conditional formatting with if formula
  • Excel conditional formatting with and
  • Excel conditional formatting icon
  • Excel conditional formatting formula if and or