Insert Three Spaces Between a Code and Department Name in Excel
Question details
Insert three spaces between a numeric code and a department name when the code length varies.

- 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.
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.
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.
If the first code and department name is in A2, click the adjacent empty cell B2.
In B2, enter =LEFT(A2,FIND(" ",A2)-1)&" "&MID(A2,FIND(" ",A2)+1,LEN(A2)) and press Enter.
Select B2 and drag its fill handle down to apply the formula to the remaining rows.

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. Open your workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Select a result cell: Click B2 if your first source value is in A2, or choose an empty cell beside your data.
- 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. Apply it to other rows: Select the formula cell and drag its fill handle down beside the remaining source values.

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.




