Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Populate an array with file names
Oops, should read;
Dim arrfiles As Range Dim strVal As String Set arrfiles = Range("MyTableRange") strVal = Application.VLookup(Range("B4726"), arrfiles, 1) "ozgrid.com" wrote in message ... Something like; Dim arrfiles As Range Dim strVal As String Set arrfiles = Range("MyTableRange") arrfiles = Application.VLookup(Range("B4726"), arrfiles, 1, True) -- Regards Dave Hawley www.ozgrid.com "Wayne" wrote in message ... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Populate an array with file names
Oops, should read;
Dim arrfiles As Range Dim strVal As String Set arrfiles = Range("MyTableRange") strVal = Application.VLookup(Range("B4726"), arrfiles, 1) "ozgrid.com" wrote in message ... Something like; Dim arrfiles As Range Dim strVal As String Set arrfiles = Range("MyTableRange") arrfiles = Application.VLookup(Range("B4726"), arrfiles, 1, True) -- Regards Dave Hawley www.ozgrid.com "Wayne" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Populate text box or combo box with external files with links to file names | Links and Linking in Excel | |||
Match file names listed in column with file names in folder | Excel Programming | |||
Populate an array that is a subset of a larger array? | Excel Worksheet Functions | |||
Populate an array with sheet names? | Excel Programming | |||
Need to randomly populate a 10x10 array of cells with 100 names - 5 people listed 20 times each... | Excel Programming |