Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I would like to be able to loop through files within a given directory and return the name of the files from within VBA Excel. The file types within the directory will be mixed, however they will be mainly text files. I am not sure if this is possible. I hope that my question makes sense. TIA. Regards Steven |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way of several. You can restrict file type such as *.xls
Sub GetFileList() Dim ThePath As String Dim fname As String Dim i As Long ThePath = "c:\A" 'ThisWorkbook.Path fname = Dir(ThePath & "\*.*") i = 1 Do While fname < "" On Error Resume Next Cells(i, "a") = fname 'MsgBox fname On Error GoTo 0 fname = Dir() i = i + 1 Loop End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "STe" wrote in message ... Hi, I would like to be able to loop through files within a given directory and return the name of the files from within VBA Excel. The file types within the directory will be mixed, however they will be mainly text files. I am not sure if this is possible. I hope that my question makes sense. TIA. Regards Steven |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you Don! That is a great help.
"Don Guillett" wrote: One way of several. You can restrict file type such as *.xls Sub GetFileList() Dim ThePath As String Dim fname As String Dim i As Long ThePath = "c:\A" 'ThisWorkbook.Path fname = Dir(ThePath & "\*.*") i = 1 Do While fname < "" On Error Resume Next Cells(i, "a") = fname 'MsgBox fname On Error GoTo 0 fname = Dir() i = i + 1 Loop End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "STe" wrote in message ... Hi, I would like to be able to loop through files within a given directory and return the name of the files from within VBA Excel. The file types within the directory will be mixed, however they will be mainly text files. I am not sure if this is possible. I hope that my question makes sense. TIA. Regards Steven |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sub Directories | Excel Programming | |||
sub directories again | Excel Programming | |||
sub directories again | Excel Programming | |||
sub directories | Excel Programming | |||
Directories | Excel Programming |