Sub RemovePathAndFileName() Dim str As String str = Range("A2").Formula MsgBox "'" & Mid(str, InStrRev(str, "]") + 1) End Sub