How to Extract file name from folder excel vba

How to Extract file name from folder excel vba

Please click for download file
https://drive.google.com/open?id=1HpUj-gBSTERFIj6tdV8FQpIrx6bmqJ_h




Below VBA code
-------------------------------------------------------
Sub myextrfile()
Dim n As Integer
Dim i As Integer
Dim xx As String

        With Application.FileDialog(msoFileDialogOpen)
        .AllowMultiSelect = True
        .Title = "PLease Select file"
        .Show
       
        n = .SelectedItems.Count
        For i = 1 To n
        xx = .SelectedItems(i)
        Range("A" & i).Value = myExtractfilename(xx)
        Next i
        End With
        End Sub
       


Function myExtractfilename(xx As Variant) As String
Dim totlen As Integer
totlen = Len(xx)
nm = WorksheetFunction.Substitute(xx, "\", "")
newlen = Len(nm)
diff = totlen - newlen
newtext = WorksheetFunction.Substitute(xx, "\", "@", diff)
sp = WorksheetFunction.Search("@", newtext)
newdiff = totlen - sp
myExtractfilename = Right(xx, newdiff)
End Function
------------------------------------------------------------------------------

About Me

author Click here for Connect FB

Click here for Linkedin

Related Post No.

Powered by Blogger.

Contact Form

Name

Email *

Message *

Search This Blog

Recent Posts

Breaking

Popular Posts

Recent Posts

Trending Topic

Breaking

Related Post No.

Pages