Back
Excel

Get data into Excel by importing it

If you’ve worked with Excel long enough, you’ve probably needed to get data into Excel so that you can analyze it, or maybe create a chart. Where does this data come from? It might come from a database or some other program, or even the web. And it can come in a variety of forms.

Whatever the case, I can guarantee you the last thing you’d ever want to do is retype it, so that option is out unless you really love typing and have tons of extra time on your hands. And copying from another program or from the web and pasting directly into a cell in a workbook might leave you with nightmarish looking results  I’ve seen this, believe me.

Luckily for you, there’s a much better way to get that data into Excel. Importing! Yes, importing is not just for purveyors of fine art or exotic foods.

When you use the Text Import Wizard, you don’t open your data source in its native program. You point Excel’s Text Import Wizard to a file, and the wizard leads you through a few steps where it looks at the rows of data in the source file and makes suggestions based on the layout of the file. Of course, you’re allowed to fine tune or override these suggestions so that the data comes into Excel just the way you want.

In this file, the four pieces of information for each employee are separated (also known as “delimited”) by a comma. The first row of the file is the column names, which are also separated by commas.

The rows of information look just like this in the text file:

Comma separated values in a source file

 

Start the Text Import Wizard

To import the contents of the file, select an empty cell in Excel this can be in a new workbook, a new worksheet in an existing workbook, or in an existing worksheet. The wizard isn’t picky!

Now, click the Data tab, and in the Get External Data group, click From Text.

The From Text command in the ribbon

 

This starts the Text Import Wizard. Go find your file, and click Open.  Notice how the Delimited button is already selected?

Step 1 of 3 in Text Import Wizard – Delimited data type

 

My data certainly is delimited by those commas, so I’ll click Next. The default delimiting character in Excel is the tab character, so it’s pre-selected here in step 2. Notice how, with the tab character as the delimiter, the preview doesn’t look right? So I see I need to change that from Tab to Comma.

Step 2 of 3 of Text Import Wizard -- Tab delimiter selected

 

Now I’ve selected Comma instead. There, see how the preview changes and looks right now?

Step 2 of 3 of Text Import Wizard -- Comma delimiter selected

 

I’ll click Next to go to the third and last step of the wizard. I can select each column and, if I want, change its data type so that it has a format I prefer or a right or left margin. But all of these columns look fine, so I’ll click Finish.

Step 3 of 3 of Text Import Wizard -- columns look right

 

Now, Excel asks me if I want to import the data right here in the current cell or create a new worksheet. That’s nice, because what if I had selected a cell that contained data I didn’t want to overwrite? Anyway, I’m in blank cell in a new worksheet, so I’ll accept Existing Worksheet and cell =$A$1, and click OK.

Where do you want to put the data?

 

And here’s my imported data! As a plus, the Text Import Wizard (in most cases) optimizes the width of the columns to fit the data so you don’t have to.

Data imported into cells and columns successfully

 

– Gary Willoughby