I do an import data from a query I created in MS Query. Lets say the columns are in order A,B,C,D,E,F in the Query Editor. Once the I save the query, return data to Excel, the imported data has a new column order
A,B,C,F,D,E -- note the F column was moved where D was.
Any ideas on how to solve this issue?
Thanks guys. Assume variables are defined correctly and disregard what the code is trying to do if you want, the preserving part is not working
For Each wks In ThisWorkbook.Worksheets
Set qt = wks.QueryTables(1)
qt.PreserveColumnInfo = True
qt.PreserveFormatting = True
If wks.Name <> "Master" And wks.Name <> "Parameters" Then
wks.Range("A2:A1000").EntireRow.Copy Destination:=Worksheets("Master").Range("A65536").End(xlUp).Offset(1, 0)
End If
Next wks