Microsoft KB Archive/99926

{|
 * width="100%"|

Excel: FILES Function Limited to 256 Filenames

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 3.0, 4.0, 4.0a, 5.0

-

SUMMARY
The FILES function returns a horizontal array of the names of all files in a specified directory or folder. The number of filenames that this function can return is limited to a maximum of 256.

MORE INFORMATION
Although the FILES function will not return more than 256 filenames at one time, you can use one of the following procedures to narrow the number of files the FILES function searches for.

Specify the Type of File You Want to Find
You can specify which files you want the FILES function to return. For example, FILES(&quot;C:\EXCEL\*.XLS&quot;) will return all files with an .XLS extension and FILES(&quot;C:\EXCEL\MAY*.XLS&quot;) will return all files that start with MAY and end with .XLS.

NOTE: This method allows the FILES function to create an array for each type of file you want a list for (provided the list of files does not exceed 256 names).

Categorize Files of Like Names in Separate Directories
You can categorize files into separate directories on the hard drive and then use the FILES function to build a list of filenames for each directory.