Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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,"+")

share|improve this question

3 Answers 3

up vote 17 down vote accepted

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.

share|improve this answer

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

=LOWER(SUBSTITUTE(E19," ","+"))
share|improve this answer
1  
An example is worth a thousand function definitions. –  Even Mien Jan 9 '12 at 13:11

Why not just use find and replace to replace the entire Haverford, PA string with the one you want. You shouldn't need a formula for this, just the built in find and replace tool.

share|improve this answer
    
it's not just a one time thing. Users will put in human friendly strings, but I need them in a different form for URLs. –  Rosarch Oct 18 '09 at 1:13

protected by Diago Oct 12 '10 at 16:31

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.