Hi all! I got some great help yesterday, so I'm hoping my luck hasn't run out.
I am running a macro that runs a query of files and compiles them into one file for me. I am using a file I'll call XYZ_Template, which holds about 40 columns of data. It queries and gets all of the data.
Unfortunately, a few of the columns get switched around. The data from AN gets put in AK, and then three columns shift one spot. So AN goes into AK, AK goes into AL, AL goes into AM, and AM goes into AN.
I cannot attach any files because it's confidential work, but I'd really appreciate some help. This is the code where it hits the snag:
Update Data Table
'------------------------------
Range("D10").Select
With Selection.QueryTable
.Connection = Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" & FullPath & "" _
, _
";Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:" _
, _
"Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global" _
, _
" Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;" _
, _
"Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
)
.CommandType = xlCmdTable
.CommandText = Array(Data_Table)
.Refresh BackgroundQuery:=False
End With
Range("D10").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
On Error GoTo errorloadfile
Thank you so much.
Bookmarks