Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
KeLee
 
Posts: n/a
Default UK Postcode formula

Hello lovely people!

I am working with UK postcodes and need to strip out the areas from them
automatically.

My original codes are in column A and the result will be in, say, column B.

UK postcodes come in one of the following 4 formats - substitute any letters
or numbers, but the syntax is correct
B1 5ZQ Letter|Number|Space|Number|Letter|Letter (LNSNLL)
SL4 5AR (LLNSNLL)
CV99 4EB (LLNNSNLL)
EC1V 4AR (LLNLSNLL)

The areas I want to return for for the above would be:
B1
SL4
CV99
EC1V

I am currently using this nested if, which works fine:
=IF(ISNUMBER(VALUE(MID(A1,4,1))),IF(ISNUMBER(VALUE (MID(A1,3,1))),LEFT(A1,4),LEFT(A1,2)),IF(ISNUMBER( VALUE(MID(A1,3,1))),LEFT(A1,4),LEFT(A1,3)))

I was wondering if there was a more elegant solution that uses the position
of the space in some way, as people have difficulty understanding the formula
above.

Thanks for any help you may provide.

KeLee
  #2   Report Post  
Roger Govier
 
Posts: n/a
Default UK Postcode formula

Hi

Try
=LEFT(A1,FIND(" ",A1)-1)

Regards

Roger Govier


KeLee wrote:
Hello lovely people!

I am working with UK postcodes and need to strip out the areas from them
automatically.

My original codes are in column A and the result will be in, say, column B.

UK postcodes come in one of the following 4 formats - substitute any letters
or numbers, but the syntax is correct
B1 5ZQ Letter|Number|Space|Number|Letter|Letter (LNSNLL)
SL4 5AR (LLNSNLL)
CV99 4EB (LLNNSNLL)
EC1V 4AR (LLNLSNLL)

The areas I want to return for for the above would be:
B1
SL4
CV99
EC1V

I am currently using this nested if, which works fine:
=IF(ISNUMBER(VALUE(MID(A1,4,1))),IF(ISNUMBER(VALUE (MID(A1,3,1))),LEFT(A1,4),LEFT(A1,2)),IF(ISNUMBER( VALUE(MID(A1,3,1))),LEFT(A1,4),LEFT(A1,3)))

I was wondering if there was a more elegant solution that uses the position
of the space in some way, as people have difficulty understanding the formula
above.

Thanks for any help you may provide.

KeLee

  #3   Report Post  
KeLee
 
Posts: n/a
Default UK Postcode formula

Thankyou that is beautiful in its simplicity.
KeLee

"Roger Govier" wrote:

Hi

Try
=LEFT(A1,FIND(" ",A1)-1)

Regards

Roger Govier


KeLee wrote:
Hello lovely people!

I am working with UK postcodes and need to strip out the areas from them
automatically.

My original codes are in column A and the result will be in, say, column B.

UK postcodes come in one of the following 4 formats - substitute any letters
or numbers, but the syntax is correct
B1 5ZQ Letter|Number|Space|Number|Letter|Letter (LNSNLL)
SL4 5AR (LLNSNLL)
CV99 4EB (LLNNSNLL)
EC1V 4AR (LLNLSNLL)

The areas I want to return for for the above would be:
B1
SL4
CV99
EC1V

I am currently using this nested if, which works fine:
=IF(ISNUMBER(VALUE(MID(A1,4,1))),IF(ISNUMBER(VALUE (MID(A1,3,1))),LEFT(A1,4),LEFT(A1,2)),IF(ISNUMBER( VALUE(MID(A1,3,1))),LEFT(A1,4),LEFT(A1,3)))

I was wondering if there was a more elegant solution that uses the position
of the space in some way, as people have difficulty understanding the formula
above.

Thanks for any help you may provide.

KeLee


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
IF formula? meris Excel Worksheet Functions 1 September 6th 05 07:14 AM
writing a formula for a colored value aaronwexler New Users to Excel 11 September 1st 05 03:11 PM
referencing named formula using INDIRECT function [email protected] Excel Worksheet Functions 19 May 11th 05 09:48 AM
Simplify formula Luke Excel Worksheet Functions 37 May 6th 05 07:21 AM
Match / Vlookup within an Array formula Hari Prasadh Excel Discussion (Misc queries) 3 February 3rd 05 04:37 PM


All times are GMT +1. The time now is 05:03 PM.

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

About Us

"It's about Microsoft Excel"