Populate an array with file names
Hi Jacob, this works well,
I've put this sub into the workbook_open area.
how can i get a vlookup function to search the array and return the file
name ie =VLOOKUP(B4726,arrfiles(),1,true) where arrfiles is the dim array
and B4726 is one of the files names?
regards
Wayne
"Jacob Skaria" wrote:
Try
Sub FilesWithinFolder()
Dim strFile As String, strFolder As String
Dim intFileCount As Integer, arrFiles As Variant
ReDim arrFiles(0)
strFolder = "d:\"
strFile = Dir(strFolder & "*.*", vbNormal)
Do While strFile < ""
ReDim Preserve arrFiles(intFileCount)
arrFiles(intFileCount) = strFile
intFileCount = intFileCount + 1
strFile = Dir
Loop
MsgBox intFileCount & " file(s) stored to array"
End Sub
--
Jacob
"Wayne" wrote:
Sorry, new to programming... Please be gentle
I need to populate an array with file names and their extension from a
specific directory.
ie
\\sim7\drawings\200\M - as the directory
then populate with:
001.dwg
002.tif
003.dgn
004.dwg
Etc, for how ever long the directory is.
Any advice? regards Wayne
|