Excel VBA macro to extract file name from file path. This macro extracts the string (file name) which is between dot (.) and backslash(\) delimiters (from right side).
' This macro shows you how to extract filename from filepath
' It extracts the filename which is between delimiters dot and backslash
filePath = "C:\Users\Desktop\files\file1.html"
firstDelPos = InStrRev(filePath, ".")
secondDelPos = InStrRev(filePath, "\")
Filename = Mid(filePath, secondDelPos + 1, firstDelPos - secondDelPos - 1)