Function Problems

Combine Two Names in Excel with an Optional And

Steven ParkerSteven Parker Nov 14, 2026 868 views

Question details

Combine names from two columns, adding the word “and” only when a second name is present.

How to Combine Two Names in Excel with an Optional And
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet has a first name in column A and an optional second name in column B.
Observed behavior
The desired result is one name when column B is blank and both names joined by “and” when column B contains a name.
Before you start

Check which columns contain the names and choose an empty column for the result. The example assumes the first name is in A2 and the optional second name is in B2.

Solution 1Recommended

Use an IF Formula to Join the Names

Use this formula to add “and” only when the second name cell is not empty.

1
Select the result cell

In Excel, click an empty cell such as C2 next to the names in A2 and B2.

2
Enter the formula

Type =IF(B2="",A2,A2&" and "&B2) in C2 and press Enter.

3
Apply it to other rows

Select C2 and drag the fill handle down the column to copy the formula to additional rows.

Use an IF Formula to Join the Names
Formula assumptions: The formula assumes A2 contains the first name. It keeps both names as entered and does not shorten matching surnames. A cell containing only spaces is not treated as blank.
Combine names in WPS Spreadsheets

Combine Names with an Optional And in WPS Spreadsheets

Use the same IF formula in WPS Spreadsheets to join two names while leaving out “and” when the second name is blank.

  1. 1. Open the worksheet: Open WPS Spreadsheets and use Open to select your Excel workbook.
  2. 2. Select an empty cell: Click C2, or another empty cell beside the two name columns.
  3. 3. Enter the formula: Type =IF(B2="",A2,A2&" and "&B2) and press Enter.
  4. 4. Fill the remaining rows: Drag the fill handle from C2 down to apply the formula to the other names, then use File > Save to save the workbook.
Adds “and” only when the second name is presentOpens and saves Microsoft Excel XLSX and XLS filesCopies the formula down a column for multiple rowsProvides a familiar spreadsheet interface
QA img-9

Frequently Asked Questions

What happens if the second name is blank?

The formula =IF(B2="",A2,A2&" and "&B2) returns only the value in A2 when B2 is blank.

How can I treat a cell containing only spaces as blank?

In the result cell, use =IF(TRIM(B2)="",A2,A2&" and "&B2). The TRIM check treats a cell containing ordinary spaces as empty.

How do I use the formula for names in different columns?

Replace A2 and B2 in the formula with the cells containing your first and second names. For example, use D2 and E2 if those are your name columns.

Can the formula remove a repeated surname?

No. The formula joins the names exactly as entered. Removing a shared surname requires a more specialized formula based on how the names are structured.