"Find" in VB


Posted by mcarter973 on November 14, 2001 11:46 AM

I'm trying to extract the last name from a full name (including middle initial). I think the formula should start from the right and find the first space.

Is there a variable in VB that is similar to the "Find" function in Excel?

Thanks.



Posted by Juan Pablo on November 14, 2001 12:15 PM

Try with InStr or...

You could use the Split function...

for example

Sub SplitString()
Dim x As Variant
x = Split("Juan Pablo González", " ")
For i = 0 To UBound(x)
Debug.Print x(i)
Next i
End Sub

Will produce:
Juan
Pablo
González

You can use n(0) to find first name, n(UBound(n)) to get last name, or anything like that.

Juan Pablo