I must be crazy for trying to use Excel (2015? It says copyright 2015) VBA on OSX. I'm trying to have Excel query some text files, called 33.txt, 34.txt, etc. in the same folder as my workbook. It chooses the file according to numbers in Column A. Excel gives me this error message: "Excel cannot find the text file to refresh this external data range.Check to make sure the text file has not been moved or renamed, then try the refresh again."
fileloc = ActiveWorkbook.Path & "/" & Range("A" & j) & ".txt"
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & fileloc, Destination:=Range("P1"))
.AdjustColumnWidth = False
.RefreshStyle = xlOverwriteCells
.Refresh BackgroundQuery:=False
End With
To make matters more frustrating, when I debug.print fileloc, it looks right. It looks like the exact location of the text file I want it to query.