Remove spaces around hyphens

Turn Reed - Park into Reed-Park, so double last names match and sort.

What you'll make

In Excel: Reed - Park becomes Reed-Park.

The formula

The formula, with a numbered bracket under each part.
NumberPartWhat it doesResult so far
1A8The name with spaces around its hyphen."Reed - Park"
2TRIM( … )Removes extra spaces, leaving single ones."Reed - Park"
3SUBSTITUTE( … ," -","-")Removes the space before the hyphen."Reed- Park"
4SUBSTITUTE( … ,"- ","-")Removes the space after the hyphen."Reed-Park"

Each bracket wraps the one above it, so Excel works from the inside out. Other spaces, as in Mary Ann, stay.

=SUBSTITUTE(SUBSTITUTE(TRIM(A8)," -","-"),"- ","-")

How to use it

Yellow bar at the top? Click Enable Editing.

  1. See it work. The Example tab shows 20 made-up names with the formula already in.
  2. Use your own names. Paste names into the green column of the Template tab. Fixed names fill in by themselves.
  3. Move them into your letter. Copy the results. Then use Paste Special and choose Values.

Before you send

Only ordinary hyphens are fixed. A spaced long dash, like Reed – Park, stays as it is, so check those rows.

Route: Get names ready for the letter

Microsoft's help: SUBSTITUTE function