listing excel file in a folder
Something went wrong in pasting this, try this instead
Sub LoopThroughDirectory()
Application.DisplayAlerts = False
x = 1
MyPath = "C:\" 'Change this to your directory
ActiveFile = Dir(MyPath & "*.xls")
Do While ActiveFile < ""
Cells(x, 1).Value = ActiveFile
x = x + 1
ActiveFile = Dir()
Loop
Application.DisplayAlerts = True
End Sub
Mike
"Mike H" wrote:
Hi,
If all you want is the filename then right click your sheet tab, view code
and paste this in and run it. Change MyPath to your desired path
Sub LoopThroughDirectory()
Application.DisplayAlerts = False
x = 1
MyPath = "C:\" 'Change this to your directory
ActiveFile = Dir(MyPath & "*.xls")
Do While ActiveFile < ""
Cells(x, 1).Value = ActiveFile
x = x + 1
ActiveFile = Dir()
Application.DisplayAlerts = True
End Sub
Mike
"asrul" wrote:
Hi All,
I want to listing all excel file in a directory.
And put in a worksheet.
How to code it.
Thank's in advance
|