Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pcakes
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with 0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David Biddulph
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

"Pcakes" wrote in message
...
I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with 0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?


If you insert your codes as text, then your formula will work OK.

If your cell actually contains the number 4587, rather than the code 04587,
you might try
=IF(LEN(A1)=4,0&LEFT(A1,2),LEFT(A1,3))

If you have other formats than the 5 digits, expand the expression to suit.
--
David Biddulph


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Marcelo
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

Hi Pcakes,

I didn't understand your question if it is a text the formula works

the postal code data are formated as a text or value?


regards
Marcelo

"Pcakes" escreveu:

I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with 0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Roger Govier
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

Hi

It sounds as though the input of the code in the first instance needs to
have included a single quote in front to force it to be text '04587

You could use =LEFT("0"&A1,3)

--
Regards

Roger Govier


"Pcakes" wrote in message
...
I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with
0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pcakes
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

They are custom formatted, as zipcode.

"Marcelo" wrote:

Hi Pcakes,

I didn't understand your question if it is a text the formula works

the postal code data are formated as a text or value?


regards
Marcelo

"Pcakes" escreveu:

I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with 0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pcakes
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

I guess I am simply not thinking correctly! What a simple fix, thanks!

"Roger Govier" wrote:

Hi

It sounds as though the input of the code in the first instance needs to
have included a single quote in front to force it to be text '04587

You could use =LEFT("0"&A1,3)

--
Regards

Roger Govier


"Pcakes" wrote in message
...
I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with
0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?




  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Roger Govier
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

Hi
Thanks for the feedback, but I think David Biddulph gave a more useful
and generalised solution.

--
Regards

Roger Govier


"Pcakes" wrote in message
...
I guess I am simply not thinking correctly! What a simple fix, thanks!

"Roger Govier" wrote:

Hi

It sounds as though the input of the code in the first instance needs
to
have included a single quote in front to force it to be text '04587

You could use =LEFT("0"&A1,3)

--
Regards

Roger Govier


"Pcakes" wrote in message
...
I have to extract the first 3-digits of a postal code, currently
using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins
with
0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?






  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pcakes
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

Thank you most helpful!

"David Biddulph" wrote:

"Pcakes" wrote in message
...
I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with 0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?


If you insert your codes as text, then your formula will work OK.

If your cell actually contains the number 4587, rather than the code 04587,
you might try
=IF(LEN(A1)=4,0&LEFT(A1,2),LEFT(A1,3))

If you have other formats than the 5 digits, expand the expression to suit.
--
David Biddulph



  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
 
Posts: n/a
Default Extracting 1st 3-digits of postal code that begin with 0

On Thu, 22 Jun 2006 06:44:02 -0700, Pcakes
wrote:

I have to extract the first 3-digits of a postal code, currently using:

=LEFT(A1,3)

However, this will not pull correctly if the postal code begins with 0.

Example: 04587 will pull 458 instead of 045.

Any suggestions?


=LEFT(TEXT(A1,"00000"),3)


--ron
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
Can someone help me put psuedo code into actual excel macro?? bxc2739 Excel Discussion (Misc queries) 1 April 22nd 06 02:58 PM
Lost my Paste Mike R Excel Discussion (Misc queries) 11 August 29th 05 12:22 AM
Formula for Extracting Alphabetic Part of a Product Code ob3ron02 Excel Worksheet Functions 5 October 30th 04 12:35 PM
Formula for Extracting Alphabetic Part of a Product Code ob3ron02 Excel Worksheet Functions 1 October 29th 04 07:05 PM
Formula for Extracting Alphabetic Part of a Product Code ob3ron02 Excel Worksheet Functions 1 October 29th 04 06:07 PM


All times are GMT +1. The time now is 04:11 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"