Insert the code into a standard module, and then use the function as normal on a spreadsheet.AndyD said:sorry, i havent used UDF's in a while - can u remind me how to use, thanks
That is exactly the same as what my "pug-ugly" UDF does.just_jon said:Hiya, TG: w/o UDF is pug-ugly, like --
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A6,"South East","SE"),"South West","SW"),"North East","NE"),"North West","NW"),"North","N"),"East","E"),"South","S"),"West","W")
AndyD said:thanks all
i think al_b_cnu's is more along the right lines because a list would need to be updated when new records are added to our database
sorry, i havent used UDF's in a while - can u remind me how to use, thanks
A
Function Abbreviate(Name As String) As String
Dim I As Integer
Dim sResult As String
Dim sTemp As String
I = InStr(Name, " ")
If I < 1 Then
Abbreviate = Name
Exit Function
End If
sResult = Left$(Name, I + 1)
sTemp = Right$(Name, Len(Name) - I)
I = InStr(sTemp, " ")
If I < 1 Then
Abbreviate = sResult
Exit Function
End If
Abbreviate = sResult & " " & Mid$(sTemp, I + 1, 1)
End Function
Function Abbreviate(Name As String) As String
Dim I As Integer
Dim sResult As String
Dim sTemp As String
I = InStr(Name, " ")
If I < 1 Then
Abbreviate = Name
Exit Function
End If
sResult = Left$(Name, I)
sTemp = Name
Do While I > 0
sTemp = Right$(sTemp, Len(sTemp) - I)
If Left$(sTemp, 1) = "(" Then
If Mid$(sTemp & "***", 3, 1) = ")" Then
sResult = sResult & " " & Left$(sTemp, 3)
Else
sResult = sResult & " " & Left$(sTemp, 1)
End If
Else
sResult = sResult & " " & Left(sTemp, 1)
End If
I = InStr(sTemp, " ")
Loop
Abbreviate = sResult
End Function
TommyGun said:Insert the code into a standard module, and then use the function as normal on a spreadsheet.AndyD said:sorry, i havent used UDF's in a while - can u remind me how to use, thanks
That is exactly the same as what my "pug-ugly" UDF does.just_jon said:Hiya, TG: w/o UDF is pug-ugly, like --
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A6,"South East","SE"),"South West","SW"),"North East","NE"),"North West","NW"),"North","N"),"East","E"),"South","S"),"West","W")
![]()