Lar Software How to Split Data Into Multiple Columns in Excel
Software

How to Split Data Into Multiple Columns in Excel


Splitting the contents of a cell into more than one column manually in Microsoft Excel would take too much time and likely result in errors. Fortunately, the program offers many ways—from built-in tools and automated processes to easy-to-use functions—to execute this data-sorting task.

Using the Text to Columns Tool

One way to split data into multiple columns in Microsoft Excel is to use the built-in Text To Columns tool. This method is handy if you prefer to work in a dialog box that guides you through the process.

For example, let’s say you want to split the names in column A into last and first names in columns B and C, respectively.

An Excel table with full names in column A, and columns B and C, headed 'Last name' and 'First name' respectively, blank.

To do this, first, select the cells in column A, and in the Data tab on the ribbon, click “Text To Columns.”

Some data in an Excel table is selected, and the Text To Columns tool in the Data tab is highlighted.

In the Convert Text to Columns Wizard, select “Delimited,” and click “Next.”

Delimited is selected in the Convert Text To Column Wizard in Excel.

A delimiter is a character, symbol, or space that is used to separate items in a sequence. In this example, the names in column A are separated by a comma and a space, so check both these options. You can see how this will affect your data in the preview at the bottom of the dialog box. If you’re happy, click “Next.”

Comma and Space are selected as delimiters in the Convert Text To Columns Wizard in Excel.

Next, clear any information in the Destination field, select the cell where you want the split data to be—in this case, cell B2—and click “Finish.”

Cell B2 is selected in the Destination field of the Convert Text To Columns Wizard in Excel.

If you want to replace the original data with the split version, select the top-left cell of the original data in the Destination field. In this example, that would be cell A2.

Now, the full names are split into last and first names in their respective columns. If needed, you can delete the original data in column A, as the split names aren’t linked in any way to the full names.

Nine people's full names in column A in Excel are split into last names and first names in columns B and C, respectively.

However, in this example, one person has two first names, and another person has two surnames. In this case, selecting the space delimiter will split these dual names into separate columns, even though you want to keep them together.

A list of names in an Excel table, with those containing more than one word in the first or last names highlighted.

To overcome this, select the comma delimiter only—not the space delimiter—in the Convert Text to Columns Wizard.

Comma is selected as a delimiter in the Convert Text To Columns Wizard in Excel.

Once the splitting process is complete, however, you’ll notice that the first names are preceded by a space, as you didn’t tell Excel to consider spaces as delimiters.

First names in column C in Excel are preceded by a space in each cell.

To remove these spaces, expand the table one column to the right to create another column for the corrected first names. Then, in cell D2, type:

=TRIM((@(First name)))

where the TRIM function removes all spaces from a text string (except for spaces between words), and (@(First name)) is a structured reference to the column in the table called “First names.”

The TRIM function being used in Excel to duplicate a column without the leading spaces.

Related


How to Use the TRIM Function in Microsoft Excel

Remove unnecessary white spaces from text strings.

When you press Enter, the first names will appear in column D, but this time, without the leading space. Also, because the data is in a formatted Excel table, the formula is duplicated automatically in the remaining cells of the column.

A list of names in column D in Excel that have been generated using the TRIM function based on column C.

Next, select the newly generated first names, and press Ctrl+C to copy them. Now, press Ctrl+Alt+V to open the Paste Special dialog box, then V to select “Values,” then Enter.

Values is selected in Microsoft Excel's Paste Special dialog box.-1

Finally, delete the column containing the spaces before the first names (C) and the original column containing the full names (A) to complete your table.

An Excel table with last names in column A and first names in column B.

Microsoft Excel has many tools to automate otherwise tedious processes, and Flash Fill is one of the most useful.

If using the Text To Columns Wizard to split data into more than one column takes too much time, this intuitive tool will help speed things up. In essence, it’s a smarter way to copy and paste the data into new cells.

Related


Short On Time? Use These Excel Tips to Speed Up Your Work

Use Excel’s time-saving tools to get jobs done.

First, select the cell where you want the first split element to go (in this case, cell B2), type the value (in this case, Smith) manually, and press Enter.

An Excel table with 'Smith' typed into the first cell in the Last Name column.

Next, in the Data tab on the ribbon, click “Flash Fill.”

Flash Fill in the Data tab on Excel's ribbon is selected.

When you run Flash Fill, Excel looks for patterns in the data, and tries to apply them to the remaining data in the range. In this example, it successfully fills in the rest of the last names from the original data down column B.

The remaininig last names in column B are completed using Excel's Flash Fill tool.

Then, repeat the process for the first names in column C—type the first value to set the pattern, press Enter, then press Ctrl+E.

The remaininig first names in column C are completed using Excel's Flash Fill tool.

Flash Fill is best used on small datasets, where you can quickly check that the tool has correctly identified the patterns in your data. However, if you’re working with many rows of data, use a more reliable tool—like Excel’s text-splitting functions—that doesn’t require you to verify the result as closely.

Using Built-In Excel Functions

Another way to split data into multiple columns is to use some of Microsoft Excel’s functions. If you choose this route, remember that the split values will be linked to the original values, meaning you need to copy (Ctrl+C) and paste them as values (Ctrl+Alt+V > V) if you want to delete the original data.

TEXTSPLIT

Excel’s TEXTSPLIT divides all content in a cell into different columns according to a delimiter you specify, and returns the result as a spilled array.

Related


Everything You Need to Know About Spill in Excel

It’s not worth crying over spilled references.

While dynamic array functions that produce spilled arrays save time by returning more than one result from one formula, bear in mind that they’re not compatible with formatted Excel tables. This means that you can only use TEXTSPLIT in regular ranges.

In this example, let’s assume you want to split the capitals and states in column A into columns B and C using a single formula.

A list of capitals and states in column A in Microsoft Excel, with columns B and C prepared to split these into individual datasets.

To do this using TEXTSPLIT, in cell B1, type:

=TEXTSPLIT(A2,", ")

where A2 is the cell containing the text you want to split, and the comma + space combination wrapped in quotation marks tells Excel that these characters together form the delimiter.

The TEXTSPLIT function in Microsoft Excel being used to split states and their capitals into separate columns.

When you press Enter and select the cell where you just typed the formula, you’ll see a blue line surrounding the result. This means that even though you only typed the formula into cell B2, the result has spilled over into cell C2.

A spilled array in Microsoft Excel, indicated by the blue line surrounding the affected cells.

Because the data is in a range that isn’t formatted as an Excel table, you need to fill the rest of the column manually. To do this, click and drag the fill handle in the bottom-right corner of cell B2 to the bottom of the range.

The fill handle in Excel is used to duplicate a formula in B2 from B3 to B10.

TEXTBEFORE and TEXTAFTER

Where TEXTSPLIT divides all the contents of a cell, the TEXTBEFORE and TEXTAFTER functions let you choose whether you want to extract the information before or after a delimiter. Also, as they’re not dynamic array functions, you can use them in data formatted as a table.

Using the same example as above, starting with the state capitals, in cell B2, type:

=TEXTBEFORE((@(Capital and State)),", ")

where (@(Capital and State)) is a structured reference to the column containing the cells you want to split, and the comma + space combination inside quotation marks tells Excel that a comma followed by a space should be considered as the delimiter. This time, however, only the text before the delimiter is returned in the result when you press Enter.

The TEXTBEFORE function in Excel is used to extact state capitals in column B.

Related


Everything You Need to Know About Structured References in Excel

Use table and column names instead of cell references.

So, to extract the last names in cell C2, type:

=TEXTAFTER((@(Capital and State)),", ")

and press Enter.

The TEXTAFTER function in Excel is used to extact states in column C.

Alongside their compatibility with Excel tables, a benefit of using TEXTBEFORE and TEXTAFTER instead of TEXTSPLIT is that the results don’t need to be in adjacent columns.

LEFT, MID, and RIGHT

Excel’s LEFT, MID, and RIGHT functions allow you to split a cell’s content at certain positions within the character string. This is particularly handy if you have a dataset of structurally consistent values, like a serial number or a code.

Related


How to Extract a Substring in Microsoft Excel

Get the important part while leaving the rest out!

In this example, the first three characters represent a country, the last three characters represent an ID, and the X or Y in the middle represent a rank. Your aim is to split these three elements into columns B, C, and D, respectively.

A list of codes in Excel, with subsequent columns prepared for splitting the codes into three different elements.

First, to extract the countries, in cell B2, type:

=LEFT((@Code),3)

where LEFT((@Code) tells Excel to read cells in the Code column from the left, and 3 tells Excel to extract the first three characters.

Countries are extracted from a code in Excel using the LEFT function.

Now, in cell D2, follow the same principle, but use the RIGHT function to extract the last three characters:

=RIGHT((@Code),3)
IDs are extracted from a code in Excel using the RIGHT function.

Finally, in cell C2, you want to extract the middle character, which is the fourth in the string. To do this, type:

=MID((@Code),4,1)

where 4 tells Excel to begin the extraction from the fourth character, and 1 tells Excel that you only want to extract a single character.

Ranks are extracted from a code in Excel using the MID function.

Now, you’ve successfully split the data in column A into three separate columns.

Using the Power Query Editor

Many people believe that Excel’s Power Query Editor is too complex for them—however, it was designed specifically to be user-friendly and is a great way to split data into multiple columns.

In this example, let’s say you have this Excel table containing various NFL teams, and you want to split these into their respective regions and team names.

A list of NFL teams, the areas, and the conferences in Excel.

First, select any cell in the data, and in the Data tab on the ribbon, click “From Table/Range” in the Get And Transform Data group.

A cell in an Excel dataset is selected, and the From Table Or Range option in the Data tab is highlighted.

This launches the Power Query Editor, which is where the magic happens!

Right-click the header of the column you want to split, and click Split Column > By Delimited.

A column header in Excel's Power Query Editor is selected via a right-click, and By Delimited in the Split Column option is selected.

Then, in the dialog box, choose the delimiter—in this case, it’s a space—and review the data to work out at which delimiters you want the data to be split. Since some regions in NFL team names have more than one word, but all their suffixes contain only one word, the text needs to be divided by the right-most delimiter.

The Split Column By Delimiter dialog box in Excel's Power Query Editor, with Space selected as the delimiter, and Right-Most Delimiter selected as the position.

Now, when you click “OK,” you’ll see the team names divided into two columns at the final delimiter. At this point, double-click the new column headers to rename them.

Columns being renamed in Excel's Power Query Editor.

Finally, click the top half of the “Close And Load” icon in the top-left corner of the Power Query Editor, and the newly split data will open in a new worksheet.

The Close And Load button in Excel's Power Query Editor is selected.

If the original data changes, be sure to click “Refresh” in the Table Design tab after selecting the table generated through the Power Query Editor. For example, if you add another team to the bottom of the table, Excel will automatically split this up according to the step you created in the Power Query Editor.

Related


How to Clean Up and Import Data Using Power Query in Excel

Don’t overlook this amazing Excel tool!


Splitting data into multiple columns isn’t the only way to rearrange data in Excel. For example, you could merge data from two columns into one column, split alternate rows into two columns, or turn vertical data horizontal. Regardless of how you want to organize your data, there’s likely a built-in Excel tool that will help you along your way.

Deixe um comentário

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Artigos relacionados

O Windows 11 está recebendo uma nova opção de personalização

Resumo O Windows 11 está ficando mais personalizável com uma próxima atualização,...

Você provavelmente não está limpando seus controladores de jogo corretamente

Considero ter um controlador limpo necessário para jogar bem. Com o tempo,...

Eu tentei o interruptor de impressão 3D 2 acessórios de mouse – e os resultados são surpreendentes!

O Switch 2 tem vários truques na manga em comparação com o...

Essa coisa está me impedindo de abandonar os PCs para sempre

Não usei um PC há um ano. Bem, quase. Há apenas um...

Compre seguidores para redes sociais, membros para grupos do Telegram, seguidores Instagram brasileiros 🚀
Comprar Seguidores