First number in a Post Code

SBM

Registered User.
Local time
Yesterday, 18:55
Joined
Aug 16, 2004
Messages
30
Hi,

I'm trying to isolate the first letter / letters of UK post codes.

Typically they are of the format ..

WS9 0JL

The obvious choice is left,2 but of course it's never that simple

some post codes are B1 7FH so left 2 gives me B1 but I need just the B

I can use Left 2 and the look at the second character to see if it is = "1" or "2" etc. but this seems a bit crude.

Is there a way I can find the position of the first number in a string (using the Instr function maybe)

That way i could Isolate the letter/s


Thanks


SBM
 
i would use the MID$ function in a for next loop and test each character for IsNumeric. When you hit the first number subtract 1 from the index then use LEFT$ to extract the Alpha characters.
 
Thanks, that's great. Sometimes you can't see the wood for the trees !
 

Users who are viewing this thread

Back
Top Bottom