Skip to main content

Join text fields without extra spaces

Read-only

Step-by-step guide · read-only · Selected D2

Loading your interactive spreadsheet…

Preparing the worksheet and formulas…

Data & tools
Task requirements

Combine A, B and C into D2:D7 with one space between fields. Remove extra ordinary spaces.

Follow the highlighted cells. Switch to Your turn to edit. Answer cells: D2, D3, D4, D5, D6, D7. Browser calculations may differ from your Excel version.

Selection & formula search

Practice stays on this device. No worksheet data is uploaded.

Notes & examples
About this lesson
Text tasks5 min·Starter

Build a readable name or label from three columns, even when the middle field is missing.

Choose the result you need

Join A, B and C with quoted spaces, then apply TRIM to remove excess ordinary spaces. An empty middle field leaves no double gap. Fill D2:D7.

=TRIM(A2&" "&B2&" "&C2)
Download this example

TRIM also collapses repeated ordinary spaces within fields. Use it when that cleanup is intended. It does not remove every Unicode space or preserve all numeric display formats.

All result formulas
D2
=TRIM(A2&" "&B2&" "&C2)
D3
=TRIM(A3&" "&B3&" "&C3)
D4
=TRIM(A4&" "&B4&" "&C4)
D5
=TRIM(A5&" "&B5&" "&C5)
D6
=TRIM(A6&" "&B6&" "&C6)
D7
=TRIM(A7&" "&B7&" "&C7)
Complete example · Name badges. Quoted strings show their exact spaces and spelling. Result cells are calculated outputs.Scroll sideways to read every column.
RowABCD
1"First field""Optional field""Last field""Joined label"
2"Ava"—"Reed""Ava Reed"
3"Leo""M.""Chen""Leo M. Chen"
4" Noor "—"Patel""Noor Patel"
5"Sam"" Lee ""Rivera""Sam Lee Rivera"
6——"Support""Support"
7"Team"7"West""Team 7 West"

These are reference examples with matching downloads. The primary worksheet has its own stated task and checks; choosing an example here leaves that worksheet and your progress unchanged.

Open the primary practice

Microsoft function reference ↗ · Browser calculations checked. Native Excel and Google Sheets recalculation of these reference files has not been verified.

All worked examples

Each example uses the source data in its own downloadable workbook. Cell references below belong to that file. Opening an example leaves the primary practice and your progress unchanged.

Join three fields with spaces

Join A, B and C with quoted spaces, then apply TRIM to remove excess ordinary spaces. An empty middle field leaves no double gap. Fill D2:D7.

=TRIM(A2&" "&B2&" "&C2)

Enter in D2 in this example's workbook. The download contains the complete source and all result formulas.

D2
"Ava Reed"
D3
"Leo M. Chen"
D4
"Noor Patel"
D5
"Sam Lee Rivera"
D6
"Support"
D7
"Team 7 West"

TRIM also collapses repeated ordinary spaces within fields. Use it when that cleanup is intended. It does not remove every Unicode space or preserve all numeric display formats.

Download this example's workbook
Join only the first and last fields

Use A and C when the optional field in B should be left out. The formula deliberately omits M. and Lee from the corresponding labels.

=TRIM(A2&" "&C2)

Enter in D2 in this example's workbook. The download contains the complete source and all result formulas.

D2
"Ava Reed"
D3
"Leo Chen"
D4
"Noor Patel"
D5
"Sam Rivera"
D6
"Support"
D7
"Team West"

The output is text in a separate cell. Source cells stay separate; Excel Merge Cells is a different operation and is not used here.

Download this example's workbook
Use TEXTJOIN and skip empty fields

TEXTJOIN inserts one chosen delimiter between nonempty values. The outer TRIM also cleans the ordinary extra spaces already present in these fields.

=TRIM(TEXTJOIN(" ",TRUE,A2:C2))

Enter in D2 in this example's workbook. The download contains the complete source and all result formulas.

D2
"Ava Reed"
D3
"Leo M. Chen"
D4
"Noor Patel"
D5
"Sam Lee Rivera"
D6
"Support"
D7
"Team 7 West"

TRUE requests empty-field skipping. TEXTJOIN alone does not clean whitespace-only text or repeated spaces inside an existing field. Desktop support depends on the installed Excel version.

Download this example's workbook
Keep a text ID with a custom separator

Clean each field, then join the nonempty values with " / ". Text "007" retains its zeros and numeric zero remains a value rather than an empty field.

=TEXTJOIN(" / ",TRUE,TRIM(A2),TRIM(B2),TRIM(C2))

Enter in D2 in this example's workbook. The download contains the complete source and all result formulas.

D2
"Unit / 007 / North"
D3
"Solo"
D4
"Middle"
D5
"A B / C"
D6
"Team / 0 / South"
D7
"Last"

A numeric 7 would not acquire leading zeros by joining it. Keep IDs as text when their spelling matters. This example deliberately collapses repeated ordinary spaces inside a field.

Download this example's workbook
UNDERSTAND THE IDEA

How it works

Pick a separator deliberately

This task builds human-readable labels with spaces. A comma, hyphen or other separator is a separate formatting choice. TRIM is useful here because extra ordinary spaces are unwanted; do not use it when repeated spaces carry meaning.

Text and number appearance

Joining a numeric value uses its underlying value, not every visual number format. A numeric 7 will not turn into 007 by itself. Store an ID as text when its leading zeros must survive, or use an explicit TEXT format in your own workbook.

Other ways to combine text

CONCAT and TEXTJOIN can also combine values. They solve the same joining task, so you do not need to learn them before trying this example. The ampersand version makes the separator and field order visible.

Read the full step-by-step walkthrough
  1. Read the parts in order

    The label should use the first field, optional middle field and final field, in that order.

  2. Connect two cells

    An ampersand joins text. Without a separator, the words run together.

    A2&B2
  3. Insert a space

    Put a space inside quotation marks between the cell references. Repeat for the third field.

    A2&" "&B2&" "&C2
  4. Handle an empty middle field

    An empty field leaves two adjacent spaces. TRIM reduces them to one and removes spaces at either end.

    TRIM(…)
  5. Fill down and test a missing field

    Fill D2:D7. Try removing the optional field, then adding it back; the formula should keep the label readable.

WHEN SOMETHING LOOKS OFF

Things to watch

Names run together

A separator must be entered as text, for example " ". A space outside quotation marks is not part of the result.

Missing fields create double spaces

TRIM cleans ordinary repeated spaces after the fields are joined.

Leading zeros disappear

A number and a text ID are different data. Preserve the ID as text if its zeros matter.

About this example

Published examples, formula filling and practice checks were tested in Chrome on October 13, 2026. Tests cover the supplied datasets and stated input rules, not every possible formula. These workbooks have not yet been independently recalculated in Microsoft Excel or Google Sheets.

Browser: testedExcel: not verifiedGoogle Sheets: not verified

Content version 2. Practice checks compare calculated results across different datasets; they do not certify every possible formula.

Reference material