The Straight Dope

Go Back   Straight Dope Message Board > Main > General Questions

Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2008, 12:12 PM
Linty Fresh Linty Fresh is offline
Guest
 
Join Date: Feb 2003
Question about separating numbers and letters in Excel

I'm kind of a n00b when it comes to using Excel functions, and I've run into the following situation:

I'm working with addresses in a field, specifically street numbers as follows:

Street Number
127A
2B

The column is in the text format.

I want to create another column containing just the number portion of the Street Number column without the letter. Is there any formula I can use to determine the length of numerals before each letter, or do I have to separate them manually?

Many thanks.

Last edited by Linty Fresh; 05-10-2008 at 12:13 PM.
Reply With Quote
Advertisements  
  #2  
Old 05-10-2008, 02:03 PM
Szlater Szlater is offline
Member
 
Join Date: Feb 2006
Location: London, UK
Posts: 2,450
If there is only one letter per cell and it's at the end of the number you should be able to do the following.

To produce a column of just the numbers use:

=LEFT(XX,(LEN(XX))-1)

Where XX = the cell containing the original data

To produce a column of just the letters use:

=RIGHT(XX,1)

Where XX = the cell containing the original data

Last edited by Szlater; 05-10-2008 at 02:04 PM.
Reply With Quote
  #3  
Old 05-10-2008, 02:12 PM
CookingWithGas CookingWithGas is online now
Charter Member
 
Join Date: Mar 1999
Location: Tysons Corner VA
Posts: 8,994
Quote:
Originally Posted by Szlater
If there is only one letter per cell and it's at the end of the number you should be able to do the following.
That works as long as there is always a letter at the end.

If there is either no letter, or only one letter, then the following will work (I have tested this):

=IF(AND(RIGHT(A1,1)>="a",RIGHT(A1,1)<"Z"), LEFT(A1,LEN(A1)-1),A1)

However, be aware that addresses are notoriously irregular and the minute you use this formula you will find an address that breaks your assumptions. There are companies who do a big business in just canonizing and validating addresses.
Reply With Quote
  #4  
Old 05-10-2008, 02:22 PM
Szlater Szlater is offline
Member
 
Join Date: Feb 2006
Location: London, UK
Posts: 2,450
Quote:
Originally Posted by CookingWithGas
That works as long as there is always a letter at the end.

If there is either no letter, or only one letter, then the following will work (I have tested this):

=IF(AND(RIGHT(A1,1)>="a",RIGHT(A1,1)<"Z"), LEFT(A1,LEN(A1)-1),A1)
You're absolutely right.

But you could also wrap your formula with VALUE() to format it nicely</weakattemptatsavingface>

=VALUE(IF(AND(RIGHT(A1,1)>="a",RIGHT(A1,1)<"Z"), LEFT(A1,LEN(A1)-1),A1))
Reply With Quote
  #5  
Old 05-12-2008, 07:05 PM
Linty Fresh Linty Fresh is offline
Guest
 
Join Date: Feb 2003
I just wanted to post back and thank everyone who helped. It really was a big help, so thanks!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:50 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Send questions for Cecil Adams to: cecil@chicagoreader.com

Send comments about this website to: webmaster@straightdope.com

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Publishers - interested in subscribing to the Straight Dope?
Write to: sdsubscriptions@chicagoreader.com.

Copyright © 2013 Sun-Times Media, LLC.