Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Extracting A Portion Of A String

Hello, Can anyone assist me with a formula to extract 2 characters out of a
string of text? For instance, the syntax of the string is:
Street Address(comma)City(comma)State(comma)Zip Code

What I need to extract are the 2 State characters.

Initially, I thought I could approach it from the righthand side of the
string, but then realized there was no consistency in the Zip Code format (ie
sometimes it wasn't included, sometimes it was 5 characters, sometimes it was
10 characters with hyphen, etc).

There is a consistent syntax that after the second comma, the next two
characters are for the state, but I'm having difficulty writing the formula
to identify those two characters.

Any and All Help is Appreciated - Thank You
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Extracting A Portion Of A String

Easiest method is probably Data Text To Columns, indicate that that the
data is delimited by commas.
If you want a formula: =MID(E3,FIND(",",E3,FIND(",",E3)+1)+1,2) will return
the two characters immediately after the second comma. (If there's actually
a space before the state code, change the second +1 to a +2).

"MWS" wrote:

Hello, Can anyone assist me with a formula to extract 2 characters out of a
string of text? For instance, the syntax of the string is:
Street Address(comma)City(comma)State(comma)Zip Code

What I need to extract are the 2 State characters.

Initially, I thought I could approach it from the righthand side of the
string, but then realized there was no consistency in the Zip Code format (ie
sometimes it wasn't included, sometimes it was 5 characters, sometimes it was
10 characters with hyphen, etc).

There is a consistent syntax that after the second comma, the next two
characters are for the state, but I'm having difficulty writing the formula
to identify those two characters.

Any and All Help is Appreciated - Thank You

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Extracting A Portion Of A String

This formula assumes that the cell with the address is in A1 and the the
State will be "Comma Space and then 2 characters"...

=TRIM(MID(A1,FIND(",",A1,FIND(",",A1,1)+1)+1,3))

It looks for the second comma and grabs the next 3 characters. It trims
those characters to remove any blanks...

--
HTH...

Jim Thomlinson


"MWS" wrote:

Hello, Can anyone assist me with a formula to extract 2 characters out of a
string of text? For instance, the syntax of the string is:
Street Address(comma)City(comma)State(comma)Zip Code

What I need to extract are the 2 State characters.

Initially, I thought I could approach it from the righthand side of the
string, but then realized there was no consistency in the Zip Code format (ie
sometimes it wasn't included, sometimes it was 5 characters, sometimes it was
10 characters with hyphen, etc).

There is a consistent syntax that after the second comma, the next two
characters are for the state, but I'm having difficulty writing the formula
to identify those two characters.

Any and All Help is Appreciated - Thank You

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Extracting A Portion Of A String

=MID(A3,FIND(",",A3,FIND(",",A3)+1)+1,2)

--
Regards,
Tom Ogilvy


"MWS" wrote in message
...
Hello, Can anyone assist me with a formula to extract 2 characters out of

a
string of text? For instance, the syntax of the string is:
Street Address(comma)City(comma)State(comma)Zip Code

What I need to extract are the 2 State characters.

Initially, I thought I could approach it from the righthand side of the
string, but then realized there was no consistency in the Zip Code format

(ie
sometimes it wasn't included, sometimes it was 5 characters, sometimes it

was
10 characters with hyphen, etc).

There is a consistent syntax that after the second comma, the next two
characters are for the state, but I'm having difficulty writing the

formula
to identify those two characters.

Any and All Help is Appreciated - Thank You



  #5   Report Post  
Posted to microsoft.public.excel.programming
MWS MWS is offline
external usenet poster
 
Posts: 53
Default Extracting A Portion Of A String

Thank You - I'll give it try!

"bpeltzer" wrote:

Easiest method is probably Data Text To Columns, indicate that that the
data is delimited by commas.
If you want a formula: =MID(E3,FIND(",",E3,FIND(",",E3)+1)+1,2) will return
the two characters immediately after the second comma. (If there's actually
a space before the state code, change the second +1 to a +2).

"MWS" wrote:

Hello, Can anyone assist me with a formula to extract 2 characters out of a
string of text? For instance, the syntax of the string is:
Street Address(comma)City(comma)State(comma)Zip Code

What I need to extract are the 2 State characters.

Initially, I thought I could approach it from the righthand side of the
string, but then realized there was no consistency in the Zip Code format (ie
sometimes it wasn't included, sometimes it was 5 characters, sometimes it was
10 characters with hyphen, etc).

There is a consistent syntax that after the second comma, the next two
characters are for the state, but I'm having difficulty writing the formula
to identify those two characters.

Any and All Help is Appreciated - Thank You

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
match value within any portion of lookup string in range Hile Excel Worksheet Functions 3 October 16th 09 12:58 PM
Formula to return a value for a portion of a text string in a cell NanGio Excel Discussion (Misc queries) 2 January 29th 09 10:36 PM
Extracting a string Peter Rooney Excel Discussion (Misc queries) 5 June 20th 06 06:34 PM
Bold a portion of concatenated string joeeng Excel Discussion (Misc queries) 1 December 8th 05 08:26 PM
How to replace defined portion of string ExcelMonkey Excel Programming 2 July 19th 05 12:21 PM


All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"