katherinec
New Member
- Joined
- Nov 23, 2005
- Messages
- 1
Hi,
I have just begun to program and write simple scripts. I have made a simple macro to import a series of text files by looping the procedure and changing the directory name each time. The text files however are imported into Excel next to each other and I want them to be underneath each other. The code is:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;D:\HIPOCAS\WindData_AnnMarie\1994\199401\HIRLAM-1994.A1", Destination:= _
Range("A1"))
.Name = "HIRLAM-1994.A1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 9, 9, 9, 9, 9)
.TextFileFixedColumnWidths = Array(8, 10, 11, 10, 8, 4, 12)
.Refresh BackgroundQuery:=False
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;D:\HIPOCAS\WindData_AnnMarie\1994\199402\HIRLAM-1994.A1", Destination:= _
Range("A1"))
.Name = "HIRLAM-1994.A1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 9, 9, 9, 9, 9)
.TextFileFixedColumnWidths = Array(8, 10, 11, 10, 8, 4, 12)
.Refresh BackgroundQuery:=False
End With
Is there a simple way of formatting the code so that each text file is importing below the previous?
many thanks,
Katherine
I have just begun to program and write simple scripts. I have made a simple macro to import a series of text files by looping the procedure and changing the directory name each time. The text files however are imported into Excel next to each other and I want them to be underneath each other. The code is:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;D:\HIPOCAS\WindData_AnnMarie\1994\199401\HIRLAM-1994.A1", Destination:= _
Range("A1"))
.Name = "HIRLAM-1994.A1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 9, 9, 9, 9, 9)
.TextFileFixedColumnWidths = Array(8, 10, 11, 10, 8, 4, 12)
.Refresh BackgroundQuery:=False
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;D:\HIPOCAS\WindData_AnnMarie\1994\199402\HIRLAM-1994.A1", Destination:= _
Range("A1"))
.Name = "HIRLAM-1994.A1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 9, 9, 9, 9, 9)
.TextFileFixedColumnWidths = Array(8, 10, 11, 10, 8, 4, 12)
.Refresh BackgroundQuery:=False
End With
Is there a simple way of formatting the code so that each text file is importing below the previous?
many thanks,
Katherine