Results 1 to 1 of 1

VBA Query rearranging my data

Threaded View

  1. #1
    Registered User
    Join Date
    01-20-2011
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    24

    VBA Query rearranging my data

    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.
    Last edited by rmunsun1; 01-21-2011 at 03:07 PM. Reason: Fonud out the issue: just had to uncheck a box in the data range properties under data and query menus. Thanks anyways!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1