Thread: Postcodes
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default Postcodes

The other problem which you haven't mentioned is that the numeric part
could be more than one character long (EG SG15 2ST)

with a postcode in A1, this formula gets to the first part of the code

=LEFT(A1,SEARCH(" ",A1)-1)

however, it doesn't resolve it - SO would suggest using a user defined
function as follows


Function pcodereturn(Postcode As String)
While Left(Postcode, 1) < " " And (Asc(Left(Postcode, 1)) < 48 Or
Asc(Left(Postcode, 1)) 57)
pcodereturn = pcodereturn & Left(Postcode, 1)
Postcode = Right(Postcode, Len(Postcode) - 1)
Wend


End Function