Splitting Text Cells


Posted by Tony J on August 17, 2001 2:43 PM

I have this problem - almost answered in similar messages posted below.
I have Names in a field - of the form Mr F A Higgs or Ms J L G Smith.
I need to split the surname into another cell so I am just left with either Higgs or Hill etc.
I'd be grateful for assistance here.
Tony Johnson

Posted by Aladin Akyurek on August 17, 2001 3:10 PM

Tony,

Add the following user-defined function to your workbook.

Function REVERSETEXT(text) As String
'
' Returns its argument, reversed
' J. Walkenbach
'
Dim TextLen As Integer
Dim i As Integer
TextLen = Len(text)
For i = TextLen To 1 Step -1
REVERSETEXT = REVERSETEXT & Mid(text, i, 1)
Next i
End Function

Then

in B2 enter: =REVERSETEXT(LEFT(REVERSETEXT(A2),SEARCH(" ",REVERSETEXT(A2))-1))

where A2 contains the first name to be split.

Copy down this as far as needed.

Aladin

=================



Posted by Tony J on August 18, 2001 10:59 AM

Aladin,
Tis works fine, Thanks.
(perhaps I should get to learn VB?)
Tony
__________________________________________ Returns its argument, reversed J. Walkenbach