marcusmark
Board Regular
- Joined
- Nov 17, 2014
- Messages
- 98
Hi,
I need help in editing the codes I used as below:
Its a code for GETOPENFILENAME with mutiple selection.
My problem is that I want the filenames only, not the whole path, just the name of the files and it is not only to be copied to a single range. Its like if I choose, 3 files, then 1st file would be in Cell A1, 2nd file in Cell A2 and so on.
Thanks in advance!
I need help in editing the codes I used as below:
Code:
Sub GetImportFileName2()
Dim FileNames As Variant
Dim Msg As String
Dim I As Integer
FileNames = Application.GetOpenFilename _
(MultiSelect:=True)
If IsArray(FileNames) Then
'Display full path and name of the files
'Msg = "You selected:" & vbNewLine
For I = LBound(FileNames) To UBound(FileNames)
Msg = Msg & FileNames(I) & vbNewLine
Range("A1") = Msg
Next I
MsgBox Msg
Else
'Cancel button clicked
MsgBox "No files were selected."
End If
End Sub
Its a code for GETOPENFILENAME with mutiple selection.
My problem is that I want the filenames only, not the whole path, just the name of the files and it is not only to be copied to a single range. Its like if I choose, 3 files, then 1st file would be in Cell A1, 2nd file in Cell A2 and so on.
Thanks in advance!