LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Francesco
 
Posts: n/a
Default Please Help for a macro reading files not in sequence

Hello

I am using WindowsXP Prof. and Excel 2003
I the folders "invoice 2006" that are in the Drives A, C end E there are 6
each excel files numbered from _001_2006 to _006_2006.xls

The macro I wrote here down, reads the files in each folder and writes the
result in sheet1 starting in cell A1

It does it but they are not read in sequence appart those in C:\ that are
right, what I get is:

A:\_002_2006.xls
A:\_001_2006.xls
A:\_003_2006.xls
A:\_004_2006.xls
A:\_005_2006.xls
A:\_006_2006.xls

C:\_001_2006.xls
C:\_002_2006.xls
C:\_003_2006.xls
C:\_004_2006.xls
C:\_005_2006.xls
C:\_006_2006.xls

E:\_006_2006.xls
E:\_001_2006.xls
E:\_002_2006.xls
E:\_003_2006.xls
E:\_004_2006.xls
E:\_005_2006.xls

Moreover if it is possible I would like to comapre the files in the
mentioned folder and if in one of them one or more files are missing in one
of the folder the macro should copy them in it.

What is wrong in the nacro?
Thanks for any help I can get on the matter
Francesco


Sub ListFiles()
Dim aryDrives
Dim oFSO
Dim n As Long
Dim i As Long


Dim sPath As String
On Error GoTo cleanUp
On Error Resume Next
aryDrives = Array("A:\", "C:\", "E:\")
Set oFSO = CreateObject("Scripting.FileSystemObject")
i = 0 'Set i to row-1 of the starting row of the data.

For n = LBound(aryDrives) To UBound(aryDrives)
sPath = aryDrives(n)
MyPath = sPath & "invoicingPRG\Invoice2006\*.*"
'MyPath = "C:\programmaFatturazione\Fatture2006\*.*" 'Modify
to suit

myFile = Dir(MyPath, vbNormal)
While myFile < ""

Cells(i, 1) = sPath & myFile 'Modify 1 here to the column you want
the List
myFile = Dir
i = i + 1
Wend
i = i + 1
Next n
cleanUp:
Application.ScreenUpdating = True
End Sub


 
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
Macro to open files isn't updating correctly telewats Excel Discussion (Misc queries) 2 February 21st 06 09:04 PM
Macro that stores all sheets as tab-delimited text files [email protected] Excel Discussion (Misc queries) 2 February 14th 06 04:02 PM
Macro for multiple open files [email protected] Excel Discussion (Misc queries) 1 February 13th 06 03:25 AM
Macro to delete first line of 200+ files Bob Dobalina Excel Discussion (Misc queries) 2 May 26th 05 10:04 PM
Macro - - Automation Jac Excel Discussion (Misc queries) 8 December 27th 04 02:42 PM


All times are GMT +1. The time now is 09:50 AM.

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

About Us

"It's about Microsoft Excel"