Let's say I have a valid .csv file path in A1 and I want to write a macro that imports whatever file is in A1. What I did was to record a macro and browsed for the specific file to see the code, then edit it such that the file path is the one in cell A1 but it's giving me a 424 error. Here's what I'm working with:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;selected file path" _ {changed this to "TEXT;"&Cells(1,1) _}
, Destination:=Range("$A$1"))
.Name = "selected file name" {What can I change this to such that it's the file name of the file path in A1? (this can vary based on user input)}
.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 = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Any help would be greatly appreciated.
Bookmarks