I have a text file with 10 rows of data, all single column so no delimiter needs to be set. In the Excel sheet, I would like to selectively import the rows like this: A1 through A5 in the Excel file gets the data from rows 1-5 from the text file; C1-C3 gets the data from rows 6-9 from the text file; D4 gets row 10.
How would I code in VBA to perform the above tasks?
This is what I currently have:
Range(dataRange).Select With Selection.QueryTable .Connection = _ "TEXT;" & dataTextFile .TextFilePlatform = 437 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With
The code was from a recorded macro. However, all 10 rows are copied into the Excel cells in the same column when I run the code.
Any help is greatly appreciated.