Function RightStr( origstring As String, searchstring As String ) As String Dim begintrim As Integer ' where to actually start the trim (necessary when searchstring is more than one character) Dim pos As Integer ' position of searchstring inside original string Dim length As Integer ' length of searchstring Dim lengthorig As Integer ' length of origstring ' get length of searchstring where original string is to be trimmed length = Len(searchstring) If length = 0 Then ' no search string was given exit returning original string RightStr = origstring Exit Function End If ' see if searchstring is in origstring pos = Instr ( 1, origstring, searchstring, 5 ) If pos>0 Then ' the search string was found, lets truncate at that point lengthorig = Len( origstring ) begintrim = lengthorig - pos - (length-1) RightStr = Right( origstring, begintrim ) Else ' the search string was not found, return the original string RightStr = origstring End If End Function Function RightBackStr ( origstring As String, searchString As String ) As String Dim begintrim As Integer ' where to actually start the trim (necessary when searchstring is more than one character) Dim pos As Integer ' position of searchstring inside original string Dim length As Integer ' length of searchstring Dim lengthorig As Integer ' length of origstring ' get length of searchstring where original string is to be trimmed length = Len(searchstring) If length = 0 Then ' no search string was given exit returning original string RightBackStr = origstring Exit Function End If ' see if searchstring is in origstring pos = Instr ( 1, origstring, searchstring, 5 ) If pos>0 Then ' the search string was found, lets truncate at that point lengthorig = Len( origstring ) RightBackStr = Left( origstring, (pos-1) ) Else ' the search string was not found, return the original string RightBackStr = origstring End If End Function Function LeftStr( origstring As String, searchstring As String ) As String Dim begintrim As Integer ' where to actually start the trim (necessary when searchstring is more than one character) Dim pos As Integer ' position of searchstring inside original string Dim length As Integer ' length of searchstring Dim lengthorig As Integer ' length of origstring ' get length of searchstring where original string is to be trimmed length = Len(searchstring) If length = 0 Then ' no search string was given exit returning original string LeftStr = origstring Exit Function End If ' see if searchstring is in origstring pos = Instr ( 1, origstring, searchstring, 5 ) If pos>0 Then ' the search string was found, lets truncate at that point lengthorig = Len( origstring ) LeftStr = Left( origstring, (pos-1) ) Else ' the search string was not found, return the original string LeftStr = origstring End If End Function