Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default can someone simplify this file listing for me

this puts all the file names located in the specified folder starting in A1

Option Explicit
Sub test()
Dim lastrow As Long
Dim MyFiles() As String
Dim NumberOfFiles As Long
Dim FilesInPath As String
Dim FileDir As Variant

FileDir = "e:\plu"
lastrow = Worksheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row

FilesInPath = Dir(FileDir & "\*.fxd")
NumberOfFiles = 0
If FilesInPath = "" Then
MsgBox "No files found"
Exit Sub
End If

Do While FilesInPath < ""

Worksheets("Sheet1").Range("A" & lastrow).Value = FilesInPath

NumberOfFiles = NumberOfFiles + 1
lastrow = lastrow + 1

ReDim Preserve MyFiles(1 To NumberOfFiles)
MyFiles(NumberOfFiles) = FilesInPath
FilesInPath = Dir()

Loop
End Sub

--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default can someone simplify this file listing for me

Option Explicit
Sub GetFiles()
Dim FileDir As String
Dim fn As String
Dim index As Long
FileDir = "e:\plu"
fn = Dir(FileDir & "\*.fxd")
Do Until fn = ""
index = index + 1
Worksheets("Sheet1").Cells(index, 1) = fn
fn = Dir()
Loop
MsgBox index & " files found"

End Sub


"Gary Keramidas" wrote:

this puts all the file names located in the specified folder starting in A1

Option Explicit
Sub test()
Dim lastrow As Long
Dim MyFiles() As String
Dim NumberOfFiles As Long
Dim FilesInPath As String
Dim FileDir As Variant

FileDir = "e:\plu"
lastrow = Worksheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row

FilesInPath = Dir(FileDir & "\*.fxd")
NumberOfFiles = 0
If FilesInPath = "" Then
MsgBox "No files found"
Exit Sub
End If

Do While FilesInPath < ""

Worksheets("Sheet1").Range("A" & lastrow).Value = FilesInPath

NumberOfFiles = NumberOfFiles + 1
lastrow = lastrow + 1

ReDim Preserve MyFiles(1 To NumberOfFiles)
MyFiles(NumberOfFiles) = FilesInPath
FilesInPath = Dir()

Loop
End Sub

--


Gary




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default can someone simplify this file listing for me

thanks patrick, i appreciate it.

--


Gary


"Patrick Molloy" wrote in message
...
Option Explicit
Sub GetFiles()
Dim FileDir As String
Dim fn As String
Dim index As Long
FileDir = "e:\plu"
fn = Dir(FileDir & "\*.fxd")
Do Until fn = ""
index = index + 1
Worksheets("Sheet1").Cells(index, 1) = fn
fn = Dir()
Loop
MsgBox index & " files found"

End Sub


"Gary Keramidas" wrote:

this puts all the file names located in the specified folder starting in
A1

Option Explicit
Sub test()
Dim lastrow As Long
Dim MyFiles() As String
Dim NumberOfFiles As Long
Dim FilesInPath As String
Dim FileDir As Variant

FileDir = "e:\plu"
lastrow = Worksheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row

FilesInPath = Dir(FileDir & "\*.fxd")
NumberOfFiles = 0
If FilesInPath = "" Then
MsgBox "No files found"
Exit Sub
End If

Do While FilesInPath < ""

Worksheets("Sheet1").Range("A" & lastrow).Value = FilesInPath

NumberOfFiles = NumberOfFiles + 1
lastrow = lastrow + 1

ReDim Preserve MyFiles(1 To NumberOfFiles)
MyFiles(NumberOfFiles) = FilesInPath
FilesInPath = Dir()

Loop
End Sub

--


Gary






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
File path listing and analysis DaveyC Excel Discussion (Misc queries) 3 December 20th 07 01:36 PM
File listing in excel PeterO Excel Programming 5 June 15th 05 11:52 AM
Want file title listing as in Excel 5.0 File>Find jeffbro27707 Excel Discussion (Misc queries) 0 April 30th 05 07:31 PM
Unix Directory/File Listing enchilada Excel Programming 0 December 10th 03 07:46 AM
Listing all external links within a file Clayton McGuire Excel Programming 3 August 20th 03 10:04 AM


All times are GMT +1. The time now is 03:44 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"