Pages

Monday, January 30, 2012

Use Split Function in UDF to reverse the words separated by space or any other special character

If you want to reverse the words separated by space or special character . For example "ashish koul " as "koul ashish" . etc Snapshot below


Use this udf

Function reverse_words(x As String, spl As String)
Dim z, s As String
z = Split(x, spl)
For j = UBound(z) To LBound(z) Step -1
s = s & spl & z(j)
Next
reverse_words = Right(s, Len(s) - 1)
End Function

Type lik reverse_words(A3," ")

a3- cell having word
" " - space as separator

No comments:

Post a Comment