Thursday, 30 August 2007

RightBack

Option Compare Text
Function RightBack(strBigString As String, strSmallString As String) As String
' Finds the text after a string
' eg =RightBack( "I love life and other stuff, do you", "," ) returns " do you"

Dim lngIndexOf As Long

lngIndexOf = InStrRev(strBigString, strSmallString)
If lngIndexOf = 0 Then
strRightBack = ""
Else
strRightBack = Mid(strBigString, lngIndexOf + 1)
End If ' we found one instance


RightBack = strRightBack

End Function

Function InStrRev2(strBigString As String, strSmallString As String) As Long
InStrRev2 = InStrRev(strBigString, strSmallString)

End Function
http://www.ozgrid.com/Excel/find-nth.htm

No comments: