![]() Streamline intricate tasks and glide through your data like a pro. Ready to supercharge your Excel tasks? Harness the power of Kutools for Excel - your ultimate time-saving tool. Transform Hours into Minutes with Kutools for Excel! How to list files in a directory to worksheet in Excel? ![]() Click OK, and you will get the folder and subfolders path, directory, name, created date and last modified date in a new workbook, see screenshot: Then press F5 key to run this code, and a Choose the folder window will pop out, then you need to select the directory that you want to list the folder and subfolder names, see screenshot:Ĥ. Sub getSubFolder(ByRef prntfld As Object)Ĭells(xRow, 1).Resize(1, 5).Value = Array(SubFolder.Path, Left(SubFolder.Path, InStrRev(SubFolder.Path, "\")), SubFolder.Name, SubFolder.DateCreated, SubFolder.DateLastModified)ģ. XWs.Cells(2, 1).Resize(1, 5).EntireColumn.AutoFit Set fso = CreateObject("Scripting.FileSystemObject") XWs.Cells(2, 1).Resize(1, 5).Value = Array("Path", "Dir", "Name", "Date Created", "Date Last Modified") XPath = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\" ![]() With Application.FileDialog(msoFileDialogFolderPicker) VBA code: List all folders and subfolder names Sub FolderNames()ĭim fso As Object, j As Long, folder1 As Object Click Insert > Module, and paste the following code into the Module Window. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.Ģ. If you want to get all the folder names from a specified directory, the following VBA code may help you, please do as this:ġ. Amazing! Using Efficient Tabs in Excel Like Chrome, Firefox and Safari! Save 50% of your time, and reduce thousands of mouse clicks for you every day! ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |