Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I borrowed a majority of this code from this NG and modified (read destroyed) it for my needs, now I can't figure what I did wrong. The macro should import a text file starting in A1, get the last row +1 (counting in column B) and repeat untill all files in the folder are processed. The only cloumns that should have data are A thru H, row count will vary. Initially it appears to work, then the macro starts moving data to other columns, like taking A1 thru A867 (A thru H) and moving it to I thru P and so on and adding blank rows from the top down? Code:
Sub aaa() 'Set Folder path Folder = "C:\MEASURE-6000\OUTPUT\Test\" 'Create worksheet "Input" With ThisWorkbook Set InputSht = Worksheets.Add( _ after:=.Sheets(.Sheets.Count)) InputSht.Name = "Input" End With 'File name Extension to find FName = Dir(Folder & "*.OUT") Do While FName < "" 'Input data file With InputSht 'Count rows in column B InputShtLastRow = .Cells(Rows.Count, "B").End(xlUp).Row 'MsgBox InputShtLastRow 'for testing 'Add data to worksheet and append each new import With .QueryTables.Add( _ Connection:="TEXT;" & Folder & FName, _ Destination:=.Range("A" & InputShtLastRow + 1)) .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 = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = True .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1) .Refresh BackgroundQuery:=False End With End With Loop End Sub -- Regards XP Pro Office 2003 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Joel - Importing multiple text files to 1 spreadsheet, now importing from excel files | Excel Programming | |||
Importing multiple files | Excel Discussion (Misc queries) | |||
Importing multiple files | Excel Programming | |||
Importing multiple files | Excel Programming | |||
Importing Multiple files nearly there | Excel Programming |