Here are three other examples that might help you understand how to use InStrRev() and Right() functions.
As Subs
Code:
Sub extraction1()
'multi step
Dim s As String
Dim FN As String 'file name
Dim pos As Integer
Dim FN_Len As Integer
FN = "dhaskdnhasklds//sdasdas/PROD_MAD_0e3433.txt"
FN_Len = Len(FN)
pos = InStrRev(FN, "/")
s = Right(FN, FN_Len - pos)
Msgbox "Filename is " & s
End Sub
Sub extraction2()
'one line
Dim s As String
Dim FN As String 'file name
FN = "dhaskdnhasklds//sdasdas/PROD_MAD_0e3433.txt"
s = Right(FN, Len(FN) - InStrRev(FN, "/"))
Msgbox "Filename is " & s
End Sub
As a function
Code:
Function extraction3(pFileName As String) As String
'one line
Dim FN As String
FN = Right(pFileName, Len(pFileName) - InStrRev(pFileName, "/"))
'return value
extraction3 = FN
End Function