Pull External Data into Excel

Often, we use Excel to summarize detail that comes from some other program or accounting system. There are essentially three ways that I am aware of to get data from another program into a destination Excel worksheet, I’ll nickname them:

  • Copy/Paste
  • Pull
  • Push

Copy/Paste

The Copy/Paste method is probably the most common.  It is when you basically view or export the data to a new Excel, csv or text file, and then copy and paste the data into the destination Excel worksheet..  It is easy to use and works well. However, other methods may be more efficient for recurring use workbooks.

Pull

You can pull the data directly from the external data source using the External Data feature of Excel. This post focuses on this feature, and the details are found below.

Push

You can also push the data from the system into a specific worksheet in an existing workbook.  Not all applications support this method, but when they do, it will save a step.

Now, let’s spend the rest of our time working through the External Data feature.

External Data

The External Data feature has been in Excel for a long time, and I first started using it in about 1997.  This feature made a big improvement in my workflow and increased my productivity.  Since then, I’ve been a huge fan of this feature! It is one of those things that is just sitting there waiting to be discovered and put to use.

External Data Overview

First, let’s start with what the feature does, and then we’ll move on to how to use it.  External data is defined as data that exists outside of the Excel workbook, in some other place.  That other place could be almost anywhere, and Excel supports pulling external data from a wide variety of sources.  Examples include data stored on web pages, in text files, or in other programs.

Programs that store large amounts of data are often built upon a database engine or platform. You, as the user, see the program’s user interface which is made up of menus, icons, dialog boxes, and forms.  Behind the scenes however, applications often store their data in a database.  It is this underlying database that Excel can often tap into with the External Data feature.

This feature doesn’t pull a single value into a single cell.  It retrieves a block of data, or a table, that will ultimately occupy a range of cells.

The External Data feature asks you to identify the location of the data you want. Once you do, Excel retrieves the data and places it into the selected worksheet. The best part of this feature lies in the fact that the External Data range is not static….it can be refreshed.  When you click the refresh button, Excel heads out to the data source and pulls back the updated data.  This improves the efficiency of recurring use workbooks because you don’t need to do the whole export, import, reformat routine that is needed with the standard copy/paste method.  You simply click the refresh button, and bam, the updated data just appears in your worksheet.

How to Pull External Data

Excel supports pulling data from a wide variety of data sources.  Examples include web pages, text files such as csv files, SQL, Access, ODBC compliant sources, and more.  The basic process is that you first identify the type of data source and then the location.  Depending on the type of source, you’ll have appropriate options. For example, if you are pulling data from an Access database, you’ll identify the table or query, and then which columns and rows you want.

For this post, I wanted to use a data source that you’ll have access to in case you want to work along. So, we’ll pull some external data from a web page.

We tell Excel that we want to retrieve data from an external source by first identifying the type of source. This is done by selecting the appropriate ribbon icon from the Data tab as shown below.

External Data Icons

 

For this simple example, we want to get data from a web page.  Our objective is to pull historical closing stock prices for Apple.  So we click the From Web icon from the Data ribbon.  This will reveal the next step in the process, which is to identify the web page.  We’ll head over to the Yahoo Finance page, so we enter the URL  http://finance.yahoo.com into the address field, as shown below.

 

Excel External Data Web

Next, we enter the stock symbol AAPL for Apple into the web page, and click the Get Quotes button.  We scroll down the page a bit, until we see the “Historical Prices” link on the left.  We click it, and we can see the daily closing prices.  We click the yellow arrow for the Prices table, and see that Excel identifies the range with a border and changes the yellow arrow to a green check, as shown below.

Excel Web Table

 

Next, we click the Import button and then tell Excel where we want the data to be placed, and bam, we have it in our Excel worksheet, as shown below.

Excel External Stock Price Data Table

 

The best part is that if we want to refresh the data, we don’t need to go through all of the setup steps again, we just need to click the refresh button on the Data ribbon tab, or, right-click the external data range and select Refresh.  Excel will go back to the data source, retrieve the updated data and drop it, automagically, into the worksheet.

Recap

For recurring processes, the External Data feature is probably more efficient than the standard copy/paste approach since you simply click the Refresh button to retrieve updated data. There are many external data sources that are compatible with this feature.  This post only provided a simple warm-up.  There is a lot more to explore as this feature supports a wide range of data types, sources, and options.  You can even set up a parameter query, where the criteria is placed in an Excel worksheet.  The criteria values stored in Excel are relayed to the external data source during the retrieval, and this makes it easy to filter the data before it hits the worksheet.  Excel Rules!

 

 

 

 

Posted in ,

Jeff Lenning

I love sharing the things I've learned about Excel, and I built Excel University to help me do that. My motto is: Learn Excel. Work Faster.

Excel is not what it used to be.

You need the Excel Proficiency Roadmap now. Includes 6 steps for a successful journey, 3 things to avoid, and weekly Excel tips.

Want to learn Excel?

Access all Undergrad and Masters lessons with a Campus Pass or CPE Pass. Includes on-demand training plus live office hours.

18 Comments

  1. raju on February 28, 2016 at 7:53 pm

    Thanks a lot for sharing knowledge. This is very useful in my daily work.

  2. Paul on April 24, 2016 at 5:23 pm

    Hi Jeff, i have Excel for Mac and i am trying to pull email addresses off a real estate site into my excel for a mass mailing. I can’t seem to find the “from web” tab on my data pulldown, so essentially i am stuck at step one. My data pull down has “from text” and “from database” and “from HTML” and “from Filemaker” I clicked on the “from HTML” but it is asking me for a file stored in my computer.
    Thanks so much for the insight. Excel is a remarkably powerful tool.

    • Kurt LeBlanc on July 11, 2016 at 6:40 am

      Hi Paul,

      Unfortunately, I do not have a copy of Excel for Mac…Hopefully another user sees this and can help you:)

      Kurt LeBlanc

  3. Andrew on February 8, 2017 at 2:13 pm

    Hi Jeff,

    Would this method work when pulling in data from a web page that requires a log in?

    Thanks

  4. Biju on April 16, 2017 at 2:56 am

    Sir,
    how can I import the data from following link.
    https://www.nseindia.com/live_market/dynaContent/live_watch/fomktwtch_OPTIDXBANKNIFTY.htm
    when we refreshing excel sheet data will be update.
    hope you can find solution.
    regards

    P.Biju

  5. Thameema on April 26, 2017 at 6:36 am

    I need to pull data from a particular link where the data is not tabularised..Is it possible ? if yes,how ?

  6. Biju on April 27, 2017 at 4:43 am

    Hi Jeff.
    as you mentioned the above links are not help to convert the data

    https://www.nseindia.com/live_market/dynaContent/live_watch/fomktwtch_OPTIDXBANKNIFTY.htm
    Error comings as “Strict Parse Error”

    Please help me.
    regards

    • Jeff Lenning on May 2, 2017 at 4:15 am

      Biju, using a Get & Transform query (PowerQuery) is my best suggestion, I’m sorry it isn’t working. Perhaps another reader can help us out.
      Thanks
      Jeff

  7. Jim Milsom on August 6, 2018 at 12:02 pm

    Jeff, I’m trying to pull the data from several excel files on a network drive. I can open these easily but when I try to pull them using query, I get an Unable to connect error: Details: file contains corrupted data. I’m thinking that it’s related to the fact these files are password protected. Is there a way to enter a password when using the Get and Transform query?

    Thanks,
    Jim

    • Jeff Lenning on August 7, 2018 at 11:45 am

      Hi Jim!
      Not to my knowledge … but I believe PQ supports other authentication methods, so, perhaps windows authentication may help … or alternatively perhaps use network security to protect the files and set folder permissions (rather than Excel passwords).
      Thanks
      Jeff

  8. Rajeevan on March 19, 2019 at 11:39 am

    Hi,
    This is helpful.
    I am trying to pull data either from another Excel document or from a Database table. I would like to know if it is possible to pull a list of data into one cell and make it a drop down.
    I also like to know if it is possible to query the Database from Excel or to reference data in the DB or another Excel doc.

  9. Elizabeth on July 5, 2019 at 10:54 am

    I’m using the Office 365 subscription version.

    When I try to follow the example, Excel tells me: “Table highlighting is disabled because this page uses Internet Explorer’s Compatibility Mode”. How do I work around that? I cannot seem to select a table to import data, even using the Get Data menu selections.

  10. Rebecca on September 17, 2019 at 2:24 pm

    I am attempting to create an automated template that pulls data from a web based platform, but having issues. Also, the platform requires a login to access the account sensitive information. Could you direct me to some examples or articles to assist with this project?

  11. Shane Eckel on December 25, 2021 at 2:34 am

    @Jeff Lenning, You are incredible!
    First of all, you’re getting one-line questions fired at you from all angles with the expectation that you’ll remote in and finish up their project while their asleep…

    “Jeff, how do we solve the pressing world hunger & clean drinking water crisis along with balancing the renewable energy debate with the need to boost the economy by EOY 2022 – in 30 words or less… ‘GO!'”

    You need to get a t-shirt made that reads, “I’ve got an article for that…” – J.Lenning

    Just read through your responses and you’ll find;
    “…see the answer in… (this brief post), (this article), (blog post), etc…
    You have all the answers (and patience) with an article or post you wrote on just about every subject covering every question.

    Anyway, good information here, thanks for offering it to the rest of us!
    -S

Leave a Comment