Excel: Replace occurences of one character with another in a String?

I want an excel formula that will change Haverford, PA to haverford,+pa. (Text is to lowercase, and spaces are replaced with plus characters.)

The following will get the first space, but not all of them:

=REPLACE(E19, SEARCH(" ", E19),1,"+")


Part of what you want to do can be accomplished with the "SUBSTITUTE" function.

This will replace specific characters in a text string with the characters you specify, in this case spaces with the + symbol.

Then to change case use the "LOWER" function.

If you nest "SUBSTITUTE" within "LOWER" you should get the change you are looking for.

The text below is taken from Excel Help.


SUBSTITUTE

Substitutes new_text for old_text in a text string. Use SUBSTITUTE when you want to replace specific text in a text string; use REPLACE when you want to replace any text that occurs in a specific location in a text string.

Syntax

SUBSTITUTE(text,old_text,new_text,instance_num)

Text is the text or the reference to a cell containing text for which you want to substitute characters.

Old_text is the text you want to replace.

New_text is the text you want to replace old_text with.

Instance_num specifies which occurrence of old_text you want to replace with new_text. If you specify instance_num, only that instance of old_text is replaced. Otherwise, every occurrence of old_text in text is changed to new_text.


LOWER

Converts all uppercase letters in a text string to lowercase.

Syntax

LOWER(text)

Text is the text you want to convert to lowercase. LOWER does not change characters in text that are not letters.


If you want to replace all spaces with the '+' character, try:

=LOWER(SUBSTITUTE(E19," ","+"))