I am trying to write a UDF to extract the first 3 or 4 characters and first character of a UK postcode (If supplied).
Examples of the various postcodes I recieve - L1 1HY, L12 1HY, LN12 1HY, L11HY, L121HY, LN121HY, L1, L12, LN12 ETC
I have started writing the below but am struggling to work out the best way to do it.
Function Halfpostcode(Postcode As String, District As Integer) As String Postcode = Trim(Postcode) Select Case IsNumeric(Application.WorksheetFunction.Search(" ", (Postcode))) Case True spaceloc = Application.WorksheetFunction.Search(" ", (Postcode)) If Len(Postcode) - spaceloc <= 3 Then Halfpostcode = Left(Postcode, Application.WorksheetFunction.Search(" ", (Postcode)))
Many Thanks in advance
Mark (CSIT17)