How to Import Text File with Multiple Delimiters into Excel

Table of Contents

Table of Contents

Importing text files into Excel can be simple when the file uses one type of delimiter such as a comma or tab. But it becomes a bit challenging when the file contains multiple delimiters like commas, semicolons, pipes, or spaces mixed together. In such cases, Excel may not correctly separate the data into columns on the first try.

In this article, we’ll learn how to import a text file with multiple delimiters into Excel using different methods.

Key Takeaways

Here’s how to import a text file with multiple delimiters using the Legacy Text Import Wizard:

➤ Open your Excel file.
➤ Go to Data >> Get Data >> Legacy Wizards >> From Text (Legacy).
➤ Select your text file and click Import.
➤ Choose Delimited, then select Comma, Semicolon, or type a custom delimiter like |.
➤ Check Treat consecutive delimiters as one.
➤ Set each column’s data format, then click Finish and choose the destination cell.
➤ Excel will now separate the data correctly using all selected delimiters.

overview image

Download Practice Workbook
1

Using the Text Import Wizard to Import Text File with Multiple Delimiters

In the following example, we have sample employee records stored in a text file. Each line contains a mix of delimiters such as commas, semicolons, pipes, and spaces. The goal is to import this text file into Excel and correctly split the data into separate columns. Save this text file in your computer as a .txt file, for example, SampleData.txt.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

The Excel file includes four types of information in four columns: Employee Name, Department, Units, and Date. We’ll import this text file and split it into those four columns in Excel despite the mix of delimiters.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

The Text Import Wizard is one of the easiest ways to bring data from a text file into Excel. It allows you to select multiple delimiters at once, such as commas, semicolons, pipes, or spaces. This method works best when you have a known set of delimiters that appear consistently in your file.

Here’s how to do it step by step:

➤ Open Excel and go to the Data tab on the ribbon.
➤ Click Get Data >> Legacy Wizards >> From Text (Legacy).

Using the Text Import Wizard to Import Text File with Multiple Delimiters

➤ If you don’t see this option, go to File and click Options >> Data >> check From Text (Legacy) under Show Legacy Data Import Wizards and click OK.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

➤ Locate your text file, for example, SampleData.txt, and click Import.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

➤ In Step 1 of the wizard, choose Delimited and click Next.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

➤ In Step 2, check multiple delimiters such as Comma, Semicolon, and Other. Type the pipe symbol |in Other if used in your file.
➤ You can also check Space if your data contains gaps between values. This ensures Excel separates all the fields correctly, even when different delimiters are used in the same line.
➤ Also, check the box for Treat consecutive delimiters as one to handle extra spaces or repeating symbols.
➤ Click Next to move to Step 3 of the wizard.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

➤ Choose the correct Column Data Format for each column:

  • Column 1 >> General (Employee Name)
  • Column 2 >> Text (Department)
  • Column 3 >> General (Units)
  • Column 4 >> Date (Date)

➤ Click Finish.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

➤ In the Import Data window, check Existing Worksheet and select where you want to place the data. For example, cell A2.
➤ Click Ok.

Using the Text Import Wizard to Import Text File with Multiple Delimiters

➤ After you complete these steps, Excel will separate the data into columns using all the selected delimiters.

Using the Text Import Wizard to Import Text File with Multiple Delimiters


2

Import Text File with Multiple Delimiters with Power Query

Power Query, also known as Get & Transform Data, is a modern and flexible way to import text files into Excel. It allows you to clean and split your data using advanced options.

Here’s how to do it step by step:

➤ Open Excel and go to the Data tab.
➤ Click Get Data >> From File >> From Text/CSV.

Import Text File with Multiple Delimiters with Power Query

➤ Select your text file, for example, SampleData.txt, and click Import.

Import Text File with Multiple Delimiters with Power Query

➤ A preview window will appear showing how Excel reads your file. Click Transform Data to open the Power Query Editor.

Import Text File with Multiple Delimiters with Power Query

➤ In the Power Query Editor, you may notice that the data is still combined in one column because Excel cannot detect multiple delimiters at once. To fix this, we’ll replace all delimiters with one standard delimiter such as a comma.
➤ Go to the Home tab and click Replace Values.

Import Text File with Multiple Delimiters with Power Query

➤ In the dialog box, replace ; with ,

Import Text File with Multiple Delimiters with Power Query

 ➤ Repeat this step to replace | and spaces with ,

Import Text File with Multiple Delimiters with Power Query

➤ This makes all rows use a single consistent delimiter.
➤ Once all delimiters are replaced, select the column, then go to Home >> Split Column >> By Delimiter.

Import Text File with Multiple Delimiters with Power Query

➤ Choose Comma ( , ) as the delimiter.
➤ Select Each occurrence of the delimiter under Split options.
➤ Click OK to split the data into separate columns.

Import Text File with Multiple Delimiters with Power Query

➤ Rename the columns as Employee Name, Department, Units, and Date.

Import Text File with Multiple Delimiters with Power Query

➤ Go to the Transform tab and set the Data Types correctly:

Employee Name >> Text
Department >> Text
Units >> Whole Number
Date >> Date

➤ Click Home >> Close & Load >> Close & Load To… to load the cleaned data back into your Excel worksheet.

Import Text File with Multiple Delimiters with Power Query

➤ Check Existing Worksheet and type the cell where you want the imported table to appear, for example, =$A$1.
➤ Finally, click OK. Excel will load the transformed data into your selected worksheet location.

Import Text File with Multiple Delimiters with Power Query

➤ After applying these steps, Excel will automatically separate the text data into four columns, even though the original file contained different delimiters.


3

Applying VBA to Import Text File with Multiple Delimiters

When your text file contains inconsistent or complex delimiters, Excel formulas or built-in tools may not separate the data correctly. In such cases, using a VBA script is the most flexible option. With just a few lines of code, you can automatically replace multiple delimiters with a single one and split the data into columns.

Here’s how to do it step by step:

➤ Open Excel and press  Alt  +  F11  to open the VBA Editor.
➤ In the VBA window, click Insert >> Module.
➤ Copy and paste the following VBA code into the module:

Sub ImportTextFileMultipleDelimiters()
    Dim FilePath As String
    Dim FileContent As String
    Dim LineData As String
    Dim RowNumber As Long
    Dim SplitValues As Variant
    Dim Item As Variant
    ' Update the file path below
    FilePath = "D:\New folder\SampleData.txt"
    Open FilePath For Input As #1
    RowNumber = 2
    Do While Not EOF(1)
        Line Input #1, LineData
        ' Replace multiple delimiters with a comma
        LineData = Replace(LineData, ";", ",")
        LineData = Replace(LineData, "|", ",")
        ' Split line by comma
        SplitValues = Split(LineData, ",")
        ' Write split data into cells
        Dim Col As Integer
        Col = 1
        For Each Item In SplitValues
            Cells(RowNumber, Col).Value = Trim(Item)
            Col = Col + 1
        Next Item
        RowNumber = RowNumber + 1
    Loop
    Close #1
    MsgBox "Text file imported successfully!", vbInformation
End Sub

Applying VBA to Import Text File with Multiple Delimiters

➤ Update the FilePath in the code with the actual location of your SampleData.txt file.
➤ Press Run >> Run Sub/UserForm  F5  to run the macro.

Applying VBA to Import Text File with Multiple Delimiters

➤ A confirmation prompt will appear, click Ok. Excel will import the text file, replace all delimiters with commas, and split the data into separate columns.

Applying VBA to Import Text File with Multiple Delimiters


Frequently Asked Question

How do I import a text file into Excel with delimiters?

You can import a text file using Excel’s Power Query option. Go to the Data tab, click Get Data >> From Text/CSV, and select your file. Excel will automatically detect the delimiter. You can also choose the correct one manually such as comma, semicolon, or tab in the preview window. Then, click Load to bring the data into your worksheet.

Why does my text file not split correctly in Excel?

This usually happens when the wrong delimiter is selected during import. Make sure you choose the correct delimiter such as comma, semicolon, or pipe, that separates your data in the text file. You can preview the split before loading it into Excel.

Can I save my import settings for future use?

Yes. When you use Power Query or VBA, Excel saves your transformation steps. You can simply refresh the query to import and clean updated text files without repeating the setup.


Wrapping Up

Importing text files into Excel becomes challenging when they contain mixed delimiters or inconsistent formatting. Knowing how to handle such files helps ensure your data is clean, structured, and ready for analysis.

This process is especially useful when you receive reports or logs saved as text files, as it saves time and reduces manual editing. Once the data is imported correctly, you can easily sort, filter, and perform calculations without worrying about misplaced or merged information.

Facebook
X
LinkedIn
WhatsApp
Picture of Sazeda Rahman

Sazeda Rahman

Sazeda Rahman Setu holds a BSc and MSc in Mathematics from National University, providing a strong foundation in analytical and logical thinking for spreadsheet work. Since May 2025, she has gained hands-on experience with Excel and Google Sheets, focusing on formulas, functions, troubleshooting, and step-by-step tutorials. She enjoys creating example datasets and clear guides to help beginners solve spreadsheet problems.
We will be happy to hear your thoughts

      Leave a reply


      Excel Insider
      Logo