The example just uses the active cell as input and outputs to immediate window.
You would need to specify in the code what cells it should be used on and where the result goes.
Function GetTextBetweenBrackets(Text As String) As String
Dim OutText As String
Dim Index As Long
Dim StartPos As Long
Dim BetweenBrackets As Boolean
For Index = 1 To Len(Text)
If Mid(Text, Index, 1) = ">" Then
BetweenBrackets = True
StartPos = Index
ElseIf Mid(Text, Index, 1) = "<" Then
If BetweenBrackets Then
OutText = OutText & Mid(Text, StartPos + 1, Index - StartPos - 1)
End If
BetweenBrackets = False
End If
Next
GetTextBetweenBrackets = OutText
End Function
Sub Test()
Dim Data As Range
Dim Cell As Range
Set Data = Range("G1:G4")
For Each Cell In Data.Cells
Cell.Offset(0, 1) = GetTextBetweenBrackets(Cell.Value)
Next
End Sub
Bookmarks