Reputation: 53
dadasdf\sdasdasd\qazxbbjj\test.txt
Above is the string in cell A1 in excelsheet,I want to extract the last word from that cell.i.e,I want only test.txt,How can I acchive that using excel function.If it is acchived by declaring any variable then also help me out.
Upvotes: 0
Views: 53
Reputation: 175748
Its clunky w/ a formula so you can do it with VBA.
To a module add;
Function GetFileName(Cell As Range)
GetFileName = Mid(Cell.Value, 1 + InStrRev(Cell.Value, "\"))
End Function
then in the cell you can =GetFileName(A1)
Upvotes: 1