Function GetLeftBackStr(bigstr As String, keystr As String) As String On Error Goto FErrorHandler Dim pos As Integer pos = Instr(1, bigstr, keystr, 5) If (pos>0) Then ' use StrRightBack to get substring GetLeftBackStr = Strleftback ( bigstr, keystr, 5, 1 ) Else ' return original string GetLeftBackStr=bigstr End If Exit Function FErrorHandler: GetLeftBackStr=bigstr Exit Function End Function