+ Reply to Thread
Results 1 to 3 of 3

Excel Macro to Update Connection String when Path and/or Filename Changed

  1. #1
    Registered User
    Join Date
    04-03-2020
    Location
    Rockmart, GA
    MS-Off Ver
    Microsoft Office 365
    Posts
    3

    Excel Macro to Update Connection String when Path and/or Filename Changed

    Hi, all!

    I have been working on an Excel workbook for awhile and I am finally conceding to the idea that I may not be able to pull this one off on my own. It's a bit different than any other code I've worked on previously.

    I have two tables mirrored from another sheet within the same workbook. My boss wants all input updated on one sheet but the final results to show on multiple sheets to be printed for the client(s). However, whenever the file is saved with a new name or in a new location, the table stops updating. How do I get the path and filename to update whenever the file is saved?

    The second issue that I've been unable to resolve is that if one or both tables contain no data, it needs to show only one blank row above the totals.

    Here's what I have so far, which is tied to a "click to refresh" button within the Input sheet:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by MandersDiva; 04-09-2020 at 02:24 AM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,654

    Re: Excel Macro to Update Connection String when Path and/or Filename Changed

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I did it for you this time. Please read forum rules. Thanks

  3. #3
    Registered User
    Join Date
    04-03-2020
    Location
    Rockmart, GA
    MS-Off Ver
    Microsoft Office 365
    Posts
    3

    Re: Excel Macro to Update Connection String when Path and/or Filename Changed

    Okay, so I've tried multiple things and I definitely need help. I want it to work when the workbook is saved and when it is opened (which will be added after I get the first part to work). It's a freelance job that will be used by employees at a company that I don't technically work for, so it will be saved in new locations and possibly under new file names. That said, the gentleman I'm doing the job for insists that the employees should not have to manually update the Connection String.

    I'm looking for a way to have the path and file name (the DBQ and the DefaultDir) automatically update in the Connection without the user needing to do anything manually. Thank you!

    Here's what I have so far (3 codes working together):

    Please Login or Register  to view this content.
    --------

    Please Login or Register  to view this content.
    --------

    Please Login or Register  to view this content.

    I've tried other codes as well, which haven't worked:

    Please Login or Register  to view this content.

+ 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. Extracting a changing filename from a path as a string
    By EnergyHOU in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-12-2016, 12:02 PM
  2. Changing connection string path to a dynamic path
    By Shevi in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-11-2014, 05:16 AM
  3. Replies: 0
    Last Post: 05-08-2014, 11:42 AM
  4. Update path to an XML file connection
    By jaume in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2013, 02:35 PM
  5. Change Path of a Data Connection String in Excel?
    By JungleJme in forum Excel General
    Replies: 0
    Last Post: 11-08-2012, 04:47 AM
  6. [SOLVED] Adding Footer with Filename Path (with UPDATE)
    By T86157 in forum Word Formatting & General
    Replies: 2
    Last Post: 05-31-2012, 04:53 PM
  7. Run Macro on cell change to update path and filename for query
    By Gary Brown in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2011, 08:05 AM

Tags for this Thread

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