ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get All Files from a Directory (https://www.excelbanter.com/excel-programming/415615-get-all-files-directory.html)

Crazyhorse

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

Bob Phillips[_3_]

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





All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com