Text between characters
Brief description:
Full description:
Code:
Function TextBetweenChar(ByVal InString As String, DefChar As String) As String 'Returns the string between the first and 2nd instance of the specified character ' Dim FirstPos As Integer, SecPos As Integer Dim DefCharCount As Integer Dim CharInd As Integer DefCharCount = (Len(InString) - Len(Replace(InString, DefChar, ""))) / Len(DefChar) If DefCharCount < 2 Then TextBetweenChar = "" Exit Function End If FirstPos = Application.WorksheetFunction.Search(DefChar, InString, 1) + Len(DefChar) SecPos = Application.WorksheetFunction.Search(DefChar, InString, FirstPos + 1) TextBetweenChar = Mid(InString, FirstPos, SecPos - FirstPos) End Function