View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Get All Files from a Directory

Sub fileExcel()
Dim MyFile, MyPath, MyName

MyFile = Dir("C:\My Documents\*xls")
X = 1
Do While MyFile < ""

X = X + 1
ThisWorkbook.Worksheets("Excel").Cells(X, 1).Value = MyFile
MyFile = Dir()
Loop
End Sub


--
__________________________________
HTH

Bob

"Crazyhorse" wrote in message
...
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