Friday, January 11, 2013

Excel VBA Macro to List All Files in a Desired Path

How to List All the Files in a Specified Directory using Excel VBA Macro
'This Macros List out all the Files Names in a Column beginning from Active Cell of an Active 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 (.xls..):
Macro to List All The Excel[.xlsx] Files Names in a Specified Path
'This Macros List out all the Excel[.xls,.xlsx,.xlsm'] Files Names in a Column Beginning From Active Cell of an Active 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 ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog