Function Problems

Insert Three Spaces Between a Code and Department Name in Excel

Natalie TaylorNatalie Taylor Nov 22, 2026 871 views

Question details

Insert three spaces between a numeric code and a department name when the code length varies.

Insert Three Spaces Between a Code and Department Name in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet column contains codes followed by department names, with a space separating each code from its name.
Observed behavior
The desired formula should find the first existing space and use it to separate the code from the department name.
Before you start

Check that each source cell contains a code followed by one ordinary space and a department name. Identify the first source cell and an empty adjacent column for the results.

Solution 1Recommended

Replace the First Separator with Three Spaces

Use this formula when codes have different lengths but each code and department name is separated by one space.

FIND locates the first space, so the formula does not depend on the code length. LEFT and MID preserve the code and department name while replacing the original separator with three spaces.

1
Select an empty cell

If the first code and department name is in A2, click the adjacent empty cell B2.

2
Enter the formula

In B2, enter =LEFT(A2,FIND(" ",A2)-1)&" "&MID(A2,FIND(" ",A2)+1,LEN(A2)) and press Enter.

3
Fill the formula down

Select B2 and drag its fill handle down to apply the formula to the remaining rows.

Replace the First Separator with Three Spaces
Check the original spacing: The formula replaces only the first space. If there are additional spaces before the department name, those spaces remain in the result.
Work with spreadsheet formulas

Insert Spaces Between Codes and Names in WPS Spreadsheets

Use the same FIND, LEFT, and MID formula in WPS Spreadsheets to separate variable-length codes from department names with three spaces.

  1. 1. Open your workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
  2. 2. Select a result cell: Click B2 if your first source value is in A2, or choose an empty cell beside your data.
  3. 3. Enter the formula: Enter =LEFT(A2,FIND(" ",A2)-1)&" "&MID(A2,FIND(" ",A2)+1,LEN(A2)) and press Enter. Adjust A2 if your source data starts elsewhere.
  4. 4. Apply it to other rows: Select the formula cell and drag its fill handle down beside the remaining source values.
Find the separator without assuming a fixed code lengthFill the formula down across multiple rowsOpen and save Microsoft Excel XLSX and XLS filesWork in a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does the formula work for codes of different lengths?

FIND(" ",A2) locates the first space in A2 instead of assuming the code has a fixed number of characters.

What if a source cell has no space?

FIND returns a #VALUE! error when it cannot find an ordinary space. Check the source cell and add a space between the code and department name.

How can I keep the results without the formulas?

Select and copy the result cells, then use Paste Special and choose Values where you want to place the text.

Why does the result contain more than three spaces?

The formula replaces only the first separator. If the source cell has multiple spaces after the code, the extra spaces remain before the department name.