Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
The Real Jd
 
Posts: n/a
Default batch import dat files

i have hundreds of dat files (regular text files that are space delimited)
that are filled with columns of data. is there a way to batch import multiple
dat files. I don't want to go through the same importing procedure for each
file.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Do you want them all in one worksheet when you're done?

Are they all in the same folder?

If yes, shell to DOS
Windows start button|Run
command
or
cmd

Go to that folder.
copy *.dat all.txt
This concatenates all those .DATs into one .Txt file.

Then close that window and open the .txt file.

=========
If you want them in different worksheets/workbooks, then I'd record a macro when
I imported one, then modify that recorded macro slightly and just rerun it to
open all the files. (Or even make it open all the files.)

I recorded a macro and tweaked it just a bit to ask for multiple files (click on
the first and ctrl-click on subsequent).

It looks like this when I'm done.

Option Explicit
Sub testme()

Dim myFileNames As Variant
Dim iCtr As Long
myFileNames = Application.GetOpenFilename _
(filefilter:="DAT Files, *.DAT", MultiSelect:=True)

If IsArray(myFileNames) Then
For iCtr = LBound(myFileNames) To UBound(myFileNames)
Workbooks.OpenText Filename:=myFileNames(iCtr), _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, FieldInfo:=Array(1, 1)
Next iCtr
End If

End Sub

each .dat file in it's own worksheet in separate workbooks.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


The Real Jd wrote:

i have hundreds of dat files (regular text files that are space delimited)
that are filled with columns of data. is there a way to batch import multiple
dat files. I don't want to go through the same importing procedure for each
file.


--

Dave Peterson
  #3   Report Post  
The Real JD
 
Posts: n/a
Default

Thanks! I'll give the dos command a go first!

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
Automatic Data Import TxRaistlin Excel Discussion (Misc queries) 2 February 4th 05 10:43 PM
how do I create qif files from Excel for import into Quicken? pb Excel Discussion (Misc queries) 2 January 16th 05 12:31 AM
Import multiple text files into a single worksheet Scott Excel Discussion (Misc queries) 0 January 13th 05 10:22 PM
How do I import Microsoft Word files into Microsoft Excel? Excel New Users to Excel 1 January 9th 05 01:03 AM
Can I import a windows explorer list of files into an Excel sprea. skeliher Excel Discussion (Misc queries) 2 December 1st 04 10:24 PM


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