How to split postal area from post code

masplin

Active Member
Joined
May 10, 2010
Messages
413
I have UK post codes in the following formats
A1
AA1
A11
AA11

I need to extract just the letters in order to look up the city. In excel I just do this with checking if the 2nd digit is a number using ISNUMBER....simple. I am a newbie to powerpivot, but have tried every trick to get the same function to work without sucess.

The problem is when you use MID on this data it doesn't recognise the 2nd digit as a number and thinks it is text. I tried to use VALUE on the 2nd character, but then throws an error if the character is actually text. I tried to use an IF statement, but doesn't like one value being TEXT and the other being a NUMBER!!!!

Must be an easy solution!!!!

Thanks

Mike
 
When a mathematical operation is performed on a numeric text character (e.g. "3") then it will coerce the text into a number (e.g. 3). So by negating the result of MID([Primary Post Code],2,1) one of two things will happen:

  1. If the 2nd character is numeric text then it'll convert it into a number so ISERROR will return FALSE.
  2. If the 2nd character is NOT numeric text then it'll return an error and ISERROR will return TRUE.
The TRUE or FALSE is then coerced into a number when it is added to 1. So the parameter of the LEFT function will either be 1+FALSE = 1 or 1+TRUE =2.
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,213,484
Messages
6,113,927
Members
448,533
Latest member
thietbibeboiwasaco

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