Importing a large amount of data using Basic

  • Thread starter Thread starter MrsButtersworth
  • Start date Start date
M

MrsButtersworth

Hi,

I have 16,000 files that need to be imported into an excel spreadsheet.
Ideally, each file (with about 100 different variables) would
automatically import into its own row. I'm looking for help in
creating something that will automatically go through a folder, open
each file (comma delimited), and put all the data from each file in its
own row.

Any help is Greatly Appreciated.
 
You can use dir() or the filesystem object to loop through all files
in a directory.

eg from:
http://groups-beta.google.com/group...es+folder+loop&rnum=16&hl=en#268c04cb38a6cbb2


Sub AllFolderFiles()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
MyPath = "C:\Temp"
ChDir MyPath
TheFile = Dir("*.xls") 'adjust extension
Do While TheFile <> ""
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
MsgBox wb.FullName
wb.Close
TheFile = Dir
Loop
End Sub


Open each file and copy the relevant information to your "master"
Excel sheet.

I would guess that 16000 files would take a long time though.

Tim.



"MrsButtersworth"
in message
news:[email protected]...
 
Back
Top