If formula and extracting letters from postcodes

nathan663

Board Regular
Joined
Dec 3, 2008
Messages
153
I am trying to extract the first 2 letters off a postcode

=Left("Cell",2) this works fine if the post code is 2 letters followed by a number eg. JE3...
However if the second digit in the postcode is a number eg. W1 i need to only take the first letter (the W) I have tried using an if formula but can not get this to work... what is the best way?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If your options are only this format AB10 4TP and W1 4TP, then you could use len with left. Something like

=left("cell",len("cell")-6)

Len gives you the length of the string, so if you have 8 characters (including space) or 7 it will always return 2 or 1 characters, respectively.
 
Upvote 0
Hi

Try :-
Code:
=IF(ISNUMBER(VALUE(MID(R30,2,1))),LEFT(R30,1),LEFT(R30,2))

where R30 is "your" cell.

NB Expiry - yours wouldn't work with "W1A 4WW" which is a valid code too.

hth

Mike
 
Last edited:
Upvote 0
Or a neater version of my previous post :-

Code:
=LEFT(R30,2---(ISNUMBER(VALUE(MID(R30,2,1)))))

hth

Mike
 
Upvote 0

Forum statistics

Threads
1,216,523
Messages
6,131,171
Members
449,627
Latest member
ChrisNoMates

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top