PDA

View Full Version : Replace/Remove word/characters from a String



suriyahi
10-02-2008, 09:43 PM
:bug: Hello,

Looking for a solution here. I have got addresses in Col A. So, cells in col. A are in many ways. What I want is, if in the cell, there is word 'United States', I want to remove it and replace with nothing. Second part is in the same column, if cells have Zip code formatted as 12345-6789, I want to remove everything after the dash ('-'). So that, it remains just 12345. For example:
In Cell (A2): St. Petersburg FL United States 33715
I want this to be: St. Petersburg FL 33715

Similarly, if cell (A3) has the following value: OVERLAND PARK KS 66210-1223. In this case I want: OVERLAND PARK KS 66210.

I appreciate your help. Thank you.

suriyahi
10-02-2008, 09:53 PM
I figured out the first part of my problem. Simple 'Find/Replace' was not working so I went to the 'Options' button and checked 'Match Case' and uncheked 'Match entire cell contents'. So, this took care of the first part. I still need help with the second part of my question. Thank you.

Bob Phillips
10-02-2008, 09:54 PM
=SUBSTITUTE(LEFT(A1,IF(ISNUMBER(FIND("-",A1)),FIND("-",A1)-1,LEN(A1)))," United States","")