+ Reply to Thread
Results 1 to 4 of 4

Dynamic source data in QUERY connections

  1. #1
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Dynamic source data in QUERY connections

    I have a sheet containing a data connection, created in Microsoft Query - importing non-null cells from one workbook to another. The connection string looks like:

    DSN=Excel Files;DBQ=C:\Users\Glenn\Desktop\Source.xlsx;DefaultDir=C:\Users\Glenn\Desktop;DriverId=1046;MaxBufferSize=2048;PageTimeout=5;

    The Command Text also specifies the source file:

    FROM `C:\Users\Glenn\Desktop\Source.xlsx`.`'1# Copy-Paste Raw$'` `'1# Copy-Paste Raw$'` etc...

    Is there anything I can do to use a different workbook (e.g. "second source" in a cell representing "second source.xlsx" ) in an entry in a worksheet cell to replace the filename in the string & the command text?

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Dynamic source data in QUERY connections

    Since you have used ODBC to link to your excel file. You need to define another dsn to extract data from second source.xlsx
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,986

    Re: Dynamic source data in QUERY connections

    OK... so what idiot-proof alternatives to ODBC can I use?

  4. #4
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Dynamic source data in QUERY connections

    Use ADO to get this done. its more versatile and you can extract data from any file.

    Have a look at this file.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Change date source from multiple connections
    By bankster in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2013, 05:38 AM
  2. [SOLVED] Data Connections: Parameterized Query of Access DB... Is it possible?
    By twointum in forum Excel General
    Replies: 4
    Last Post: 06-27-2012, 01:25 PM
  3. Replies: 2
    Last Post: 05-24-2012, 08:43 AM
  4. Automate Data Web Connections using list of source sites on another sheet
    By benasalisbury in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2012, 10:15 AM
  5. Run Away Data Connections / Query?
    By mrIslic in forum Excel General
    Replies: 0
    Last Post: 10-04-2011, 10:18 AM

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