How to Open a Text File in Excel (.TXT)

Last Updated: March 01, 2024
puneet-gogia-excel-champs

- Written by Puneet

Sometimes when you working with data, you need to get data from multiple sources. And text files are one of the most popular sources for data. Sometime , when you donwload data from a web portal, or a export it from inventory software, it comes in a .txt file.

open-text-file-in-excel

To use that data further in the Excel, you need to open that file in the Excel. And the good news is Excel is pretty much amazing in files like .txt and .csv. And, in this tutorial, we will look at the three different ways to open a text file in Excel.

Steps to Open a Text File in Excel

To open a text file in Excel, you can simply open it using the open dialog box. Once you open it, Excel will show you the text-to-columns option to import data into the worksheet. If data is in tabular form, you need a few clicks to add it to Excel.

  1. First, you need to go to the File tab; in the File tab, you have the Open option. In the Open option, click on Browse to open the dialog box to save the file.
    click-open-and-browse
  2. After that, in the bottom-right corner of the dialog box, there is a drop-down. From that drop-down, make sure to have “All Files” selected. This allows Excel to open all formats of files in Excel.
    select-all-files
  3. Next, you need to locate the folder where you have the file which you want to open. Then, click on the file that you want to open the file.
    select-the-text-file
  4. You have the text-to-columns dialog box. Click on the next button to go to the next step, and checkmark “My data has headers.” If your data already has headers.
    text-to-column-dialog-box
  5. In the next step, checkmark the “Tab”, and click Next. This tells Excel to separate data using the tab into columns. Even when you check-mark the tab, it shows you the snapshot of the data in the data preview.
    checkmark-tab-and-click-next
  6. In the end, click on the Finish button to get the data into the worksheet. Once you click, it will open the text file in Excel and get the data in the worksheet.
    click-finish

Below is the data that you get in the end when you open it in Excel. Once you open a text file in Excel, you’ll get the data, but it won’t save that text file as an Excel file. Save it as an Excel workbook, go to the File ⇢ Save As.

data-opened-in-sheet

Benefits of this Method – When you open a text file (txt) in Excel, you open it within the Excel. And when you make changes, all those changes go directly into the text file. So when you want to make chages to the file after opening it, it is the best way for this.

Options in the Import Wizard to Know When you are Opening a Text File

There are a few options in the import wizard which you can use to get better control over when you opening a text file in Excel.

  • My Data has Header – When you tick-mark this option when you have headers in the data. And you want to treat those header as there are in the Excel file.
  • Start Import at the Row – When you open a .txt file, Excel taks it as tabular form, and you can choose the row from which you want to import the data.
  • Delimiters – If your data is not in the tabualr form and have a delimiter in between the values, in that case, you can specify the delimiter to split data into columns.
  • Column data format – You can specify the format of the each column before opening the data from the text file. Select the each column in the “Data Preview” and then specify the data format.
  • Settings for Numeric Data – There are specific setting which you can use for numeric data. For example, indetifing the decimals, thousand seperator, etc.

Open a Text File in Excel with Power Query

Using Power Query is a game changer when you want to open the text file but actually don’t want to make changes to the file itself. Power Query connects the text file as a data source and then you can get all the data from it. Let’s do this with the steps below.

  1. To open power query, you need to go to the “Data” tab, and from there, click on the “Get Data” drop down. From there, in “From File”, go to the “From Text/CSV”. This option helps you to connect a text file with the Power Query as a source.
    open-text-file-with-power-query
  2. Now, once you get the “Import Data” dialog box, you need to get locate the text file which you want to open (connect). Click on it and then click on the “Import” button.
    select-file-and-import
  3. After that, it will show you a preview of the dat which you have in the .txt file which you have loaded to the power query. Here you have two options to use one is to load the data and the second is to open the power query editor and transform the data. From now, click on the “Load”.
    load-the-file
  4. In the end, you have the data in the worksheet from the text file. This data is only linked with the text file and you need to save this Excel file seperatly.
    data-loaded-in-sheet

The best part of using the power query for importing data from the text file is it’s dynamic. When you update data in the text file, you can update it in Excel by clicking on the refresh button.

Power Query also allow you to open and get data from multiple files, you checkout this tutorial to learn mroe on this.

Copy-Paste Data from Text File to Excel Worksheet

You can also use the simple copy and paste method. To get the data from a text file. Usually, text file doesn’t have much formatting other than Font Size, Font Style, etc. And when you copy and paste data from it that formatting won’t get pasted there in the Excel file.

Once you open the text file and use the keyboard shortcut Ctrl + A to select all the data from the text file.

copy-paste-data-from-text-to-excel

Go to the worksheet, and then select the cell on which you want to paste the data. After that, use the keyboard shortcut Ctrl + V to paste the data.

text-data-pasted-into-sheet