View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Crazyhorse Crazyhorse is offline
external usenet poster
 
Posts: 18
Default Get All Files from a Directory

Sub fileExcel()
Dim MyFile, MyPath, MyName

MyFile = Dir("C:\My Documents\*xls")
x = 2
Do While MyFile < ""
ThisWorkbook.Worksheets("Excel").Cells(x, 1).Value = MyFile
MyFile = Dir()
If MyFile < "" Then
x = x + 1
ThisWorkbook.Worksheets("Excel").Cells(x, 1).Value = MyFile
End If
Loop

End Sub