Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate text box or combo box with external files with links to file names retterjr Links and Linking in Excel 0 February 18th 12 03:47 AM
Match file names listed in column with file names in folder K[_2_] Excel Programming 1 March 16th 09 04:26 PM
Populate an array that is a subset of a larger array? Jeff Excel Worksheet Functions 1 September 25th 07 12:51 AM
Populate an array with sheet names? Steve Excel Programming 1 January 30th 07 08:14 PM
Need to randomly populate a 10x10 array of cells with 100 names - 5 people listed 20 times each... Kevin Lyons[_2_] Excel Programming 3 February 8th 04 08:28 PM


All times are GMT +1. The time now is 02:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"