Combine Two Names in Excel with an Optional And
Question details
Combine names from two columns, adding the word “and” only when a second name is present.

- 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.
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.
Use an IF Formula to Join the Names
Use this formula to add “and” only when the second name cell is not empty.
In Excel, click an empty cell such as C2 next to the names in A2 and B2.
Type =IF(B2="",A2,A2&" and "&B2) in C2 and press Enter.
Select C2 and drag the fill handle down the column to copy the formula to additional rows.

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. Open the worksheet: Open WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Select an empty cell: Click C2, or another empty cell beside the two name columns.
- 3. Enter the formula: Type =IF(B2="",A2,A2&" and "&B2) and press Enter.
- 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.

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.




