+ Reply to Thread
Results 1 to 2 of 2

vba to change query source path

  1. #1
    Registered User
    Join Date
    07-17-2012
    Location
    Egypt
    MS-Off Ver
    Excel 2016
    Posts
    3

    vba to change query source path

    Hello,
    I've created 2 queries from data tab>New Query to import csv file
    I need vba to change source path from "C:\Folder1\" to "C:\Folder2\" for query 1 and do the same for query 2
    I did lot of google search but all solutions focus on ODBC queries
    Could anyone help me please?
    Last edited by ma7amadk; 04-07-2017 at 01:44 AM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: vba to change query source path

    I will assume you are importing data (Data -> From Text). The following will let you change the path and the file name call it from another subroutine with the syntax: Refresh_Data DirectoryName, FileName. In this case, the connection name is called qry_data. Change that to meet your needs.

    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. [SOLVED] Allow User Change Data Source Path
    By Kburges in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2013, 05:17 PM
  2. Replies: 1
    Last Post: 11-01-2009, 05:01 AM
  3. [SOLVED] Q: Change pivot table source path?
    By Mark in forum Excel General
    Replies: 1
    Last Post: 07-26-2006, 07:45 PM

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