Hi All,
I have created a macro that imports csv files, but what I really want to do is refresh instead of import. Therefore I would be adding a new csv file "on top" of an old one. With my code, it was always adding a new csv file to the right of the old one which is not what I wanted. Instead of adding a query table, I thought I could just index it, but that doesn't do anything at all.
If anyone could help me out, that'd be great! I thought I had posted this before earlier, but I can't find it anywhere, so I apologize if there is a repeat.
If Len(Dir((sItem & "\" & fileName & " _ " & l & " " & i & " " & testSetup & ".csv"))) <> 0 Then
With Sheets("0 0").QueryTables(1) '.Add(Connection:= _
newString _
, Destination:=Sheets("0 0").Cells(10, 1))
.FillAdjacentFormulas = True
.Name = fileName & "_" & l & " " & i & " " & testSetup
.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 = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=True
End With
End If
Bookmarks