Friday, 11 January 2013

Excel VBA Macro to List All Files in a Desired Path

Excel VBA Macro to List All the Files in a Specified Directory
'This Macros List out all the Files Names in a Column Beginning From Active Cell of a Sheet
      Sub ListAllFiles()

      Dim Files As String
         Files = Dir("C:\Users\Tamatam\Desktop\Temp\*.*")

         Do While Len(Files) > 0
               ActiveCell.Formula = Files
               ActiveCell.Offset(1, 0).Select
               Files = Dir()
         Loop

      End Sub
------------------------------------------------------------------------------------------------------------------------ Specific Files Type Case:
Macro to List All The Excel[.xlsx] Files in a Specified Path
'This Macros List out all the Excel[.xls,.xlsx,.xlsm'] Files Names in a Column Beginning From Active Cell of a Sheet
      Sub ListAll_Xls_Files()

      Dim Files As String
         Files = Dir("C:\Users\Tamatam\Desktop\Temp\\*.xls*")

         Do While Len(Files) > 0
               ActiveCell.Formula = Files
               ActiveCell.Offset(1, 0).Select
               Files = Dir()
         Loop

      End Sub

Note:
You can use this macro to list out any files type from any desired path in your PC.

Thanks.,
Tamatam
    

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts