Hi Everyone,
I'm having problems with the following code and can't work out what I'm getting wrong, is anyone able to offer me so advice?
I have a very simple Userform with two text boxes on it, one for the folder path and the other for the file extension. The objective of the code is to publish a list of all file names of a particular extension into an excel sheet but at the moment it's doing nothing I found the code on a forum and just adapted slightly but I have a feeling I'm not referencing the path name correctly?
Any ideas greatfully received, Many Thanks
I'm having problems with the following code and can't work out what I'm getting wrong, is anyone able to offer me so advice?
I have a very simple Userform with two text boxes on it, one for the folder path and the other for the file extension. The objective of the code is to publish a list of all file names of a particular extension into an excel sheet but at the moment it's doing nothing I found the code on a forum and just adapted slightly but I have a feeling I'm not referencing the path name correctly?
Any ideas greatfully received, Many Thanks
Code:
Private Sub CommandButton1_Click()
Folder = TextBox1.text
Extension = TextBox2.text
First = True
RowCount = 1
Do
If First = True Then
FName = Dir(Folder & "\" & Extension)
First = False
Else
FName = Dir()
End If
If FName <> "" Then
Range("A" & RowCount) = FName
RowCount = RowCount + 1
End If
Loop While FName <> ""
End Sub