Data, Data Tools, and Text to Columns can be used to separate data in a single column into multiple columns, such as if you have full names in one column and need a column with first names and a column with last names. When you select the command, a wizard dialog box opens to help you through the process. In step 1 of the wizard, select whether the text is Delimited or Fixed Width (see the next sections for definitions of Delimited and Fixed Width). In step 2, you provide more details on how you want the text separated. In step 3, you tell Excel the basic formatting to apply to each column.
If you have data in the columns to the right of the column you are separating, Excel overwrites the data. Be sure to insert enough blank columns to not overwrite your existing data before beginning Text to Columns. See the section “Inserting an Entire Row & Column” in chapter 2, “Working with Workbooks, Sheets, Rows, Columns, and Cells,” for instructions on how to insert columns.
Working with Delimited Text
Delimited text is the text that has some character, such as a comma, tab, or space, separating each group of words that you want to be placed into its own column. To separate delimited text into multiple columns, follow these steps:
Highlight the range of text to be separated.
Go to Data, Data Tools, Text to Columns. The Convert Text to Columns Wizard opens.
Select Delimited from step 1 of the wizard, as shown in Figure 3.6, and click Next.
Figure 3.6. Select the Delimited option to separate text joined by delimiters, such as commas, spaces, or tabs.
Select one or more delimiters used by the grouped text, as in Figure 3.7, and click Next.
Figure 3.7. Select the Delimited option to use the comma as a delimiter between the city, state, and ZIP Code.If you need more than one delimiter but one of the delimiters is used normally in the text, such as the space between city names and the space between a state and ZIP Code (Sioux Falls, SD 57057), consider running Text to Columns twice: once to separate the city (Sioux Falls) from the state ZIP Code (SD 57057) and again to separate the state and ZIP Code.
For each column of data, select the data format. For example, if you have a column of ZIP Codes, you need to set the format as Text so any leading zeros are not lost. But be warned—setting a column to Text prevents Excel from properly identifying formulas entered into that column.
Click Finish. The text is separated, as shown in Figure 3.8.
Figure 3.8. Using Text to Columns with a comma delimiter separated the city from the state and ZIP Code. Run the wizard again on the state ZIP Code column with space as a delimiter to split up that data.
Working with Fixed-Width Text
The fixed-width text describes text where each group is a set number of characters. You can draw a line down all the records to separate all the groups, as shown in Figure 3.9. If your text doesn’t look like it’s fixed width, try changing the font to a fixed-width font, such as Courier. It’s possible that it’s fixed-width text in disguise.
Figure 3.9. Use the Fixed Width option when each group in the data has a fixed number of characters.
To separate fixed-width text into multiple columns, follow these steps:
Highlight the range of cells that includes text to be separated.
Go to Data, Text to Columns.
Select Fixed Width from step 1 of the wizard and click Next.
Excel will guess where the column breaks should go, as shown in Figure 3.9. You can move a break by clicking and dragging it to where you want it, insert a new break by clicking where it should be, or remove a break by double-clicking it. Click Next. Don’t worry about leading spaces—Excel will remove them for you.
For each column of data, select the data format. For example, if you have a column of ZIP Codes, you need to set the format as Text so any leading zeros are not lost, as shown in Figure 3.10. But be warned—setting a column to Text prevents Excel from properly identifying formulas entered into that column.
Figure 3.10. In step 3 of the wizard, set the format of each column. If you have numeric text, such as ZIP Codes, make sure you configure the wizard to treat the column as text so you don’t lose any leading zeros.