read fold contents

  • Thread starter Thread starter kevcar40
  • Start date Start date
K

kevcar40

hi
I would like to read all the files in a folder
the files beginning with a "W" i would like to copy the file name into
excel as a list

any ideas how this is done

thanks

kevin
 
Hi,

Try this with the path changed to your required path

Sub LoopThroughDirectory()
Application.DisplayAlerts = False
'Change this to your directory
MyPath = "C:\"
activefile = Dir(MyPath & "*.xls")
Do While activefile <> ""
If UCase(Left(activefile, 1)) = "W" Then
Cells(Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1, 1) = activefile
End If
activefile = Dir()
Loop
Application.DisplayAlerts = True
End Sub

Mike
 
Hi,

Try this with the path changed to your required path

Sub LoopThroughDirectory()
Application.DisplayAlerts = False
'Change this to your directory
MyPath = "C:\"
activefile = Dir(MyPath & "*.xls")
Do While activefile <> ""
  If UCase(Left(activefile, 1)) = "W" Then
Cells(Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1, 1) = activefile
  End If
activefile = Dir()
Loop
Application.DisplayAlerts = True
End Sub

Mike






- Show quoted text -

thank you works a treat
 
Back
Top