{"id":5765,"date":"2023-04-05T14:50:05","date_gmt":"2023-04-05T14:50:05","guid":{"rendered":"https:\/\/www.bizinfograph.com\/resource\/?p=5765"},"modified":"2023-04-05T18:37:41","modified_gmt":"2023-04-05T18:37:41","slug":"how-to-find-the-file-names-list-from-a-folder-in-excel","status":"publish","type":"post","link":"https:\/\/www.bizinfograph.com\/resource\/how-to-find-the-file-names-list-from-a-folder-in-excel\/","title":{"rendered":"How to find the File Names list from a folder in Excel?"},"content":{"rendered":"<p>On the first day of my job in a small consulting company, I was staffed on a short project for three days.<\/p>\n<p>The task was easy.<\/p>\n<p>On the network disk, there were many folders, each containing hundreds of files.<\/p>\n<p>I had to take the following three actions:<\/p>\n<p><strong>Step 1:<\/strong> Copy the file&#8217;s name after selecting it.<\/p>\n<p><strong>Step 2:<\/strong> In Excel, paste that name in a column and press Enter.<\/p>\n<p>Steps 1 and 2 should be repeated for the next file.<\/p>\n<p>Sounds easy, doesn&#8217;t it?<\/p>\n<p>It was time-consuming and simplistic.<\/p>\n<p>If I had known the proper methods, I could have completed what took me three days in a matter of minutes.<\/p>\n<p>This tutorial will demonstrate various methods to simplify and expedite the entire process which makes this possible, with or without VBA, making it both fast and easy.<\/p>\n<p><strong>This Tutorial Covers:<\/strong><\/p>\n<ol>\n<li><a href=\"#using-power-query-editor-feature\"><strong>Using Power Query Editor feature<\/strong><\/a><\/li>\n<li><a href=\"#using-find-&amp;-replace-feature\"><strong>Using Find &amp; Replace feature<\/strong><\/a><\/li>\n<li><a href=\"#using-vba-code-get-a-list-of-all-the-file-names-from-a-folder\"><strong>Using VBA code get a list of all the file names from a folder<\/strong><\/a><\/li>\n<li><a href=\"#using-vba-code-get-a-list-of-all-the-file-names-with-a-specific-extension\"><strong>Using VBA code get a list of all the file names with a specific extension<\/strong><\/a><\/li>\n<\/ol>\n<ol>\n<li><strong id=\"using-power-query-editor-feature\">Using Power Query Editor feature:<\/strong><\/li>\n<\/ol>\n<p><strong>The steps to find the files names list in excel using Power Query Editor feature are described below:<\/strong><\/p>\n<p><strong>Step 1:<\/strong> Choose &#8220;Get Data&#8221; under &#8220;Get &amp; Transform&#8221; by going to the &#8220;Data&#8221; option in the ribbon. After that, select &#8220;From File&#8221; from the menu, then click &#8220;From Folder&#8221; from the list of options.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-5768\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-1.png\" alt=\"File Names list from a folder\" width=\"417\" height=\"391\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-1.png 417w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-1-300x281.png 300w\" sizes=\"(max-width: 417px) 100vw, 417px\" \/><\/p>\n<p><strong>Step 2:<\/strong> Include the parent folder&#8217;s folder path that you want to ask for. You can either use the Browse option to choose the folder or copy and paste this from the address bar of the Windows file explorer. After entering the file path, it will show something like the below:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-5769\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-2.png\" alt=\"File Names list from a folder\" width=\"454\" height=\"170\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-2.png 454w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-2-300x112.png 300w\" sizes=\"(max-width: 454px) 100vw, 454px\" \/><\/p>\n<p><strong>Step 3:<\/strong> You can verify the result to make sure it&#8217;s in the right folder by looking at the preview that will appear. To change the query, click the &#8220;Transform Data&#8221; button. You can choose to edit the files if you want to see more details about them. If not, you can &#8220;Load&#8221; the query without making any changes.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-5770\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-3.png\" alt=\"File Names list from a folder\" width=\"570\" height=\"431\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-3.png 570w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-3-300x227.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/p>\n<p><strong>Step 4:<\/strong> You don&#8217;t need this column titled &#8220;Content&#8221; if all you&#8217;re after is a summary of the file names from the folders. You can transfer data into this column from numerous files and folders.<\/p>\n<p>To remove the \u201cContent\u201d column, right-click on the column heading and pick &#8220;Remove&#8221; from the menu.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5771\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-4.png\" alt=\"File Names list from a folder\" width=\"342\" height=\"408\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-4.png 342w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-4-251x300.png 251w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/p>\n<p><strong>Step 5:<\/strong> We can view more specific details about the files by expanding the Attributes column. In the absence of that, we will only be able to see the Folder Path, Name, Extension, Date accessed, Date modified, and Date made, which may be all you need to see.<\/p>\n<p>On the &#8220;Attributes&#8221; section, left click on the filter icon.<\/p>\n<p>The various file characteristics you want to appear in the query results can be selected or deselected.<\/p>\n<p>If you don&#8217;t want your new attribute columns to be prefixed, uncheck &#8220;Use original column name as prefix.&#8221; (ie. Attributes.Kind)<\/p>\n<p>Click the &#8220;OK&#8221; option.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5772\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-5.png\" alt=\"File Names list from a folder\" width=\"352\" height=\"403\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-5.png 352w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-5-262x300.png 262w\" sizes=\"(max-width: 352px) 100vw, 352px\" \/><\/p>\n<p>The additional categories you selected will now be visible in the query editor preview.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5773\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-6.png\" alt=\"File Names list from a folder\" width=\"641\" height=\"390\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-6.png 641w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-6-300x183.png 300w\" sizes=\"(max-width: 641px) 100vw, 641px\" \/><\/p>\n<p><strong>Step 7:<\/strong> Press the &#8220;Close &amp; Load&#8221; option from the &#8220;Home&#8221; tab.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5774\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-7.png\" alt=\"File Names list from a folder\" width=\"344\" height=\"155\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-7.png 344w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-7-300x135.png 300w\" sizes=\"(max-width: 344px) 100vw, 344px\" \/><\/p>\n<p>A table with details on all the files in your selected subdirectory will appear after the query has loaded. Then, you can filter this table to focus on specific file types, or you can sort on dates to locate a file&#8217;s most current version.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5775\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-8.png\" alt=\"File Names list from a folder\" width=\"639\" height=\"217\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-8.png 639w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-8-300x102.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/p>\n<p>Through this method, you can get a list of file names as well as any additional information you desire.<\/p>\n<p><strong id=\"using-find-&amp;-replace-feature\">2. Using Find &amp; Replace feature:<\/strong><\/p>\n<p><strong>The steps to find file name list in excel using Find &amp; Replace feature are described below:<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5776\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-9.png\" alt=\"File Names list from a folder\" width=\"495\" height=\"286\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-9.png 495w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-9-300x173.png 300w\" sizes=\"(max-width: 495px) 100vw, 495px\" \/><\/p>\n<p><strong>Step 2:<\/strong> Holding the Shift key, right-click while hovering over your choice. Holding the Shift key while performing a right press is important. Select &#8220;copy as path&#8221; in the pop-up box. This transfers all of the files&#8217; file paths to the Clipboard.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5777\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-10.png\" alt=\"File Names list from a folder\" width=\"358\" height=\"361\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-10.png 358w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-10-298x300.png 298w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-10-150x150.png 150w\" sizes=\"(max-width: 358px) 100vw, 358px\" \/><\/p>\n<p><strong>Step 3:<\/strong> Paste the file paths to your desired sheet in Excel.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5779\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-11.png\" alt=\"File Names list from a folder\" width=\"462\" height=\"304\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-11.png 462w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-11-300x197.png 300w\" sizes=\"(max-width: 462px) 100vw, 462px\" \/><\/p>\n<p><strong>Step 4:<\/strong> Using Excel&#8217;s replace feature; we&#8217;ll get the filenames and remove the folder path.<\/p>\n<p>So, select and copy the folder path by double-clicking on one of the cells.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5780\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-12.png\" alt=\"File Names list from a folder\" width=\"640\" height=\"325\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-12.png 640w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-12-300x152.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>Step 5:<\/strong> Press CTRL+H to open &#8220;Find and Replace&#8221; dialog box. Click on &#8220;Replace&#8221; option and paste the folder path in the &#8220;Find what&#8221; box. Then click on &#8220;Replace All&#8221;. Click on &#8220;Close&#8221;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5781\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-13.png\" alt=\"File Names list from a folder \" width=\"383\" height=\"177\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-13.png 383w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-13-300x139.png 300w\" sizes=\"(max-width: 383px) 100vw, 383px\" \/><\/p>\n<p>The result looks like below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5782\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-14.png\" alt=\"File Names list from a folder\" width=\"265\" height=\"403\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-14.png 265w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-14-197x300.png 197w\" sizes=\"(max-width: 265px) 100vw, 265px\" \/><\/p>\n<p>Through this method, you can find files name list from folder can be copied here in Excel.<\/p>\n<p><strong id=\"using-vba-code-get-a-list-of-all-the-file-names-from-a-folder\">3. Using VBA code get a list of all the file names from a folder:<\/strong><\/p>\n<p>This approach can be used if you&#8217;re comfortable using VBA.<\/p>\n<p>Let me now give you the VBA code to build the function that will return a list of all the file names from an Excel folder.<\/p>\n<p><strong>Function GetFileNames(ByVal FolderPath As String) As Variant<\/strong><\/p>\n<p><strong>Dim Result As Variant<\/strong><\/p>\n<p><strong>Dim i As Integer<\/strong><\/p>\n<p><strong>Dim MyFile As Object<\/strong><\/p>\n<p><strong>Dim MyFSO As Object<\/strong><\/p>\n<p><strong>Dim MyFolder As Object<\/strong><\/p>\n<p><strong>Dim MyFiles As Object<\/strong><\/p>\n<p><strong>Set MyFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<\/strong><\/p>\n<p><strong>Set MyFolder = MyFSO.GetFolder(FolderPath)<\/strong><\/p>\n<p><strong>Set MyFiles = MyFolder.Files<\/strong><\/p>\n<p><strong>ReDim Result(1 To MyFiles.Count)<\/strong><\/p>\n<p><strong>i = 1<\/strong><\/p>\n<p><strong>For Each MyFile In MyFiles<\/strong><\/p>\n<p><strong>Result(i) = MyFile.Name<\/strong><\/p>\n<p><strong>i = i + 1<\/strong><\/p>\n<p><strong>Next MyFile<\/strong><\/p>\n<p><strong>GetFileNames = Result<\/strong><\/p>\n<p><strong>End Function<\/strong><\/p>\n<p>GetFileNames will be created by the aforementioned code and made available for use in the spreadsheets. (just like regular functions).<\/p>\n<p><strong>Where to save this code?<\/strong><\/p>\n<p><strong>To copy this code into the VB Editor, follow the instructions below:<\/strong><\/p>\n<p><strong>Step 1:<\/strong> Press ALT+F11 to open VB Editor. Right-click any spreadsheet object you&#8217;re working in in the VB Editor, select &#8220;Insert&#8221;, and then select &#8220;Module&#8221;. Press the &#8220;R&#8221; key while holding down the Control key if you can&#8217;t see the Project Explorer.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5783\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-15.png\" alt=\"File Names list from a folder\" width=\"534\" height=\"410\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-15.png 534w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-15-300x230.png 300w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><\/p>\n<p><strong>Step 2:<\/strong> To put the aforementioned code into the module code window, double-click the Module object.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5784\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-16.png\" alt=\"File Names list from a folder\" width=\"637\" height=\"346\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-16.png 637w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-16-300x163.png 300w\" sizes=\"(max-width: 637px) 100vw, 637px\" \/><\/p>\n<p><strong>How Should This Function Be Used?<\/strong><\/p>\n<p><strong>The methods to use this function in a worksheet are as follows:<\/strong><\/p>\n<p><strong>Step 1:<\/strong> The folder address of the folder from which you want to display the file names should be entered in any cell (I\u2019m entering it in column E1).<\/p>\n<p>Enter the following formula (I&#8217;m entering it in column A2) in the cell where you want the list to appear:<\/p>\n<p><strong>=IFERROR(INDEX(GetFileNames($E$1),ROW()-1),&#8221;&#8221;)<\/strong><\/p>\n<p>To obtain a list of all the files, copy and paste the formula into the columns below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5785\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-17.png\" alt=\"File Names list from a folder\" width=\"638\" height=\"351\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-17.png 638w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-17-300x165.png 300w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/p>\n<p>Take note that I used that cell in the GetFileNames formula after entering the folder address in another cell. The folder location can also be hard coded in the formula, as shown below:<\/p>\n<p><strong>=IFERROR(INDEX(GetFileNames(&#8220;C:\\Users\\Hashim\\OneDrive\\Desktop\\Important File\\&#8221;),ROW()-1),&#8221;&#8221;)<\/strong><\/p>\n<p>In the method above, we used ROW()-1 and worked our way up to the second row. This ensured that the formula would be increased by 1 as I copied it into the columns below. You can just use ROW() if you&#8217;re putting the formula in the first row of a column.<\/p>\n<p><strong>How does this formula work?<\/strong><\/p>\n<p>This formula utilizes a combination of Excel functions to extract file names from a folder and list them in a column in Excel.<\/p>\n<p>First, the GetFileNames formula is used to retrieve an array of all the file names in the folder.<\/p>\n<p>Next, the INDEX function is used to display one file name per cell in a column, starting from the first file name in the array.<\/p>\n<p>Finally, the IFERROR function is used to replace any #REF! errors with a blank cell when there are no more file names to list.<\/p>\n<p>To summarize, this formula extracts file names from a folder and lists them in a column in Excel, while handling any errors that may occur during the process.<\/p>\n<p><strong id=\"using-vba-code-get-a-list-of-all-the-file-names-with-a-specific-extension\">4. Using VBA code to get a list of all the file names with a specific extension:<\/strong><\/p>\n<p>When you want to get a list of all the file names from a folder in Excel, the aforementioned formula works wonderfully.<\/p>\n<p>What if, however, you only want the titles of PDF files, DOCX files, or file names that contain a particular keyword?<\/p>\n<p>You can then employ a slightly different code in that scenario.<\/p>\n<p>The code for retrieving all file names containing a particular phrase is provided below. (or of a specific extension).<\/p>\n<p><strong>Function GetFileNamesbyExt(ByVal FolderPath As String, FileExt As String) As Variant<\/strong><\/p>\n<p><strong>Dim Result As Variant<\/strong><\/p>\n<p><strong>Dim i As Integer<\/strong><\/p>\n<p><strong>Dim MyFile As Object<\/strong><\/p>\n<p><strong>Dim MyFSO As Object<\/strong><\/p>\n<p><strong>Dim MyFolder As Object<\/strong><\/p>\n<p><strong>Dim MyFiles As Object<\/strong><\/p>\n<p><strong>Set MyFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<\/strong><\/p>\n<p><strong>Set MyFolder = MyFSO.GetFolder(FolderPath)<\/strong><\/p>\n<p><strong>Set MyFiles = MyFolder.Files<\/strong><\/p>\n<p><strong>ReDim Result(1 To MyFiles.Count)<\/strong><\/p>\n<p><strong>i = 1<\/strong><\/p>\n<p><strong>For Each MyFile In MyFiles<\/strong><\/p>\n<p><strong>If InStr(1, MyFile.Name, FileExt) &lt;&gt; 0 Then<\/strong><\/p>\n<p><strong>Result(i) = MyFile.Name<\/strong><\/p>\n<p><strong>i = i + 1<\/strong><\/p>\n<p><strong>End If<\/strong><\/p>\n<p><strong>Next MyFile<\/strong><\/p>\n<p><strong>ReDim Preserve Result(1 To i &#8211; 1)<\/strong><\/p>\n<p><strong>GetFileNamesbyExt = Result<\/strong><\/p>\n<p><strong>End Function<\/strong><\/p>\n<p>GetFileNamesbyExt, a function that can be used in the worksheets, will be created by the aforementioned code. (just like regular functions).<\/p>\n<p>The folder address and the extension keyword are the two parameters for this function. An array of file names with the specified suffix is returned. All file titles in the given folder will be returned if no extension or keyword is provided.<\/p>\n<p><strong>Syntax:<\/strong> =GetFileNamesbyExt(\u201cFolder Location\u201d,\u201dExtension\u201d)<\/p>\n<p><strong>Where to save this code?<\/strong><\/p>\n<p><strong>To copy this code into the VB Editor, follow the instructions below:<\/strong><\/p>\n<p><strong>Step 1:<\/strong> Press ALT+F11 to open VB Editor. Right-click any spreadsheet object you&#8217;re working in in the VB Editor, select &#8220;Insert&#8221;, and then select &#8220;Module&#8221;. Press the &#8220;R&#8221; key while holding down the Control key if you can&#8217;t see the Project Explorer.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5786\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-18.png\" alt=\"File Names list from a folder\" width=\"538\" height=\"414\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-18.png 538w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-18-300x231.png 300w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/p>\n<p><strong>Step 2:<\/strong> To put the aforementioned code into the module code window, double-click the Module object.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5787\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-19.png\" alt=\"File Names list from a folder\" width=\"639\" height=\"354\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-19.png 639w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-19-300x166.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/p>\n<p><strong>How Should This Function Be Used?<\/strong><\/p>\n<p><strong>The methods to use this function in a worksheet are as follows:<\/strong><\/p>\n<p><strong>Step 1:<\/strong> The folder address of the folder from which you want to display the file names should be entered in any cell. This is what I typed into column E1.<\/p>\n<p>Enter the extension (or the keyword) you want all the file titles to have in a cell. This is what I typed into column F1.<\/p>\n<p>Enter the following formula (I&#8217;m entering it in column A2) in the cell where you want the list to appear:<\/p>\n<p><strong>=IFERROR(INDEX(GetFileNamesbyExt($E$1,$F$1),ROW()-1),&#8221;&#8221;)<\/strong><\/p>\n<p>To obtain a list of all the files, copy and paste the formula into the cells below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5788\" src=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-20.png\" alt=\"File Names list from a folder\" width=\"638\" height=\"228\" srcset=\"https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-20.png 638w, https:\/\/www.bizinfograph.com\/resource\/wp-content\/uploads\/2023\/03\/File-Names-list-from-a-folder-20-300x107.png 300w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/p>\n<p>These are a few techniques for finding file names list from a folder in Excel.<\/p>\n<p><strong>For ready-to-use Dashboard Templates:<\/strong><\/p>\n<ol>\n<li><a href=\"https:\/\/www.bizinfograph.com\/dashboard-templates#Finance\" target=\"_blank\" rel=\"noopener\">Financial Dashboards<\/a><\/li>\n<li><a href=\"https:\/\/www.bizinfograph.com\/dashboard-templates#Sales\" target=\"_blank\" rel=\"noopener\">Sales Dashboards<\/a><\/li>\n<li><a href=\"https:\/\/www.bizinfograph.com\/dashboard-templates#Human-Resource\" target=\"_blank\" rel=\"noopener\">HR Dashboards<\/a><\/li>\n<li><a href=\"https:\/\/www.executiveknowledge.org\/dashboard-templates\/35\" target=\"_blank\" rel=\"noopener\">Data Visualization Charts<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>On the first day of my job in a small consulting company, I was staffed on a short project for three days. The task was easy. On the network disk, there were many folders, each containing hundreds of files. I had to take the following three actions: Step 1: Copy the file&#8217;s name after selecting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[649],"tags":[650],"class_list":["post-5765","post","type-post","status-publish","format-standard","hentry","category-file-names-list","tag-file-names-list"],"_links":{"self":[{"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/posts\/5765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/comments?post=5765"}],"version-history":[{"count":4,"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/posts\/5765\/revisions"}],"predecessor-version":[{"id":5907,"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/posts\/5765\/revisions\/5907"}],"wp:attachment":[{"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/media?parent=5765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/categories?post=5765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bizinfograph.com\/resource\/wp-json\/wp\/v2\/tags?post=5765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}