Function ySplit(ByVal pTarget As String, _
pItem As String, _
Optional ShowLeft As Boolean = True) _
As String
'*******************************************
'Purpose: Splits a string to the left or
' right of pItem
'Coded by: raskew
'Inputs: 1) ySplit("The quick+ brown fox", "+", True)
' 2) ysplit("The quick+ brown fox", "+", False)
'Output: 1) The quick
' 2) brown fox
'*******************************************
Dim strLeft As String
Dim strRight As String
Dim n As Integer
n = InStr(pTarget, pItem)
If n = 0 Then
ySplit = pTarget
Else
ShowLeft = IIf(IsMissing(ShowLeft), True, ShowLeft)
strLeft = Left(pTarget, n - 1)
strRight = Mid(pTarget, n + 1)
ySplit = IIf(ShowLeft, strLeft, strRight)
End If
End Function