Hi,

I'm trying to setup a macro to import a series of data files.

I currently have:

Sheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\...\4cm 0_9Hz 1o.dat" _
, Destination:=Range("$A$1"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = ":"
.TextFileColumnDataTypes = Array(1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False

NewName = Range("B4").Value
ActiveSheet.Name = NewName

End With

However, I would like to be able to define the file locations before, say:

Filename(1) = C:\...\4cm 0_9Hz 1o.dat
Filename (2) = C:\...\4cm 0_9Hz 1o.dat

etc.

And then use a for loop to churn out all of the worksheets. I tried:

Filename(1) = C:\...\4cm 0_9Hz 1o.dat

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;Filename(1)" _
, Destination:=Range("$A$1"))

But just got an error. I assume the term "TEXT;Filename(1)" is incorrect. I've tried removing TEXT etc, but my knowledge of code is none-existant and I am working on purely trial and error basis. Could anybody tell me what I am doing wrong?

Thank you in advance,

AS