Hi All,
well my post from yesterday was answered quickly (THANKS Pike) but I noticed a quirk in my data sets that necessitates some additional coding.
I have multiple test results (as CSV text files) in a directory that I can now import at the push of a button, but I noticed that some of the test results have an additional 16 columns of data in (they have 4 channels tested not just 2). Upshot is that during the test import, I need to see if the value of the field (always column "AP") reads as "Line3-DCVoltage3", ( this unit has the extra lines being tested), if this is true then I need to insert 16 blank cells (to the right of course) before the next cell is imported (would now be "BF")
Or to put it another way, if "AP" = "Line3-DCVoltage3", then skip to column "BF" and continue with the text import, else do nothing .
Code currently reads as follows:
Dim strPath As String
Dim strFile As String
strPath = "C:\ont\"
strFile = Dir(strPath & "*.txt")
Do While strFile <> ""
With ActiveWorkbook.ActiveSheet
With .QueryTables.Add(Connection:="TEXT;" & strPath & strFile, _
Destination:=.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0))
.Parent.Name = Replace(strFile, ".txt", "")
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End With
strFile = Dir
Loop
Thanks for your help
Bookmarks