I suspect that regular expressions could indeed do this better but this is the codethat I knew how to write (now incorporating @YowE3K's "error case" and his more awake - despite his professed tiredness - understanding of how brackets within brackets should be treated):-
Private Function LastBracket(ByVal Txt As String) As String
' 08 Jan 2018
Dim Fun As String
Dim x As Integer, y As Integer
Dim n As Integer, m As Integer
For n = 0 To Len(Txt) - 1
Fun = Fun & Mid(Txt, Len(Txt) - n, 1)
Next n
n = InStr(Fun, ")") ' remove trailing text
If n Then
Fun = Mid(Fun, n)
Else
Exit Function ' no bracket found
End If
Do
n = InStr(m + 1, Fun, "(")
If n Then
Txt = Left(Fun, n)
m = n
x = Len(Txt) - Len(Replace(Txt, "(", ""))
y = Len(Txt) - Len(Replace(Txt, ")", ""))
Else
Exit Function ' paired bracket not found
End If
Loop Until x = y
Fun = Txt
Txt = ""
For n = 1 To Len(Fun) - 2
Txt = Txt & Mid(Fun, Len(Fun) - n, 1)
Next n
LastBracket = Txt
End Function
It will return a null string if there is no bracketed text or the brackets are empty. Here are the tests I ran.
Private Sub TestUnpack()
Debug.Print "Result = "; LastBracket("Some; Text")
Debug.Print "Result = "; LastBracket("Some; Text()")
Debug.Print "Result = "; LastBracket("Some(Text)")
Debug.Print "Result = "; LastBracket("Some(Text)(here)")
Debug.Print "Result = "; LastBracket("Some (text) (might be (here))")
Debug.Print "Result = "; LastBracket("Some (text) (might be (situated (here)))")
Debug.Print "Result = "; LastBracket("Some (text) (might be (situated (here))) not here")
Debug.Print "Result = "; LastBracket("abc ((def) ghi (jkl) (mno (pqr)) stu) vwx")
End Sub