+ Reply to Thread
Results 1 to 9 of 9

Updating a link in a file extension dynamically based on a field in that spreadsheet

  1. #1
    Registered User
    Join Date
    08-09-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Updating a link in a file extension dynamically based on a field in that spreadsheet

    Hi guys

    I am new to the forum and have been searching around to see if I could figure this out but can't. Any help would be greatly appreciated.

    I have a file that is pulling one value from a field in a closed file. Link below:

    ='W:\Client\C\Client name\2013\Test File\Test Name\filedname\List\[filename.xls]test'!$H$60

    What I am trying to do is replace the \fieldname\ with a cell from the sheet so it will dynamically pull a new value when that field is updated.

    So if G7 has the link ='W:\Client\C\Client name\2013\Test File\Test Name\TEST1\List\[filename.xls]test'!$H$60 and in the same sheet if B2 has the value TEST1, when I change B2 to TEST5 that the link changes to ='W:\Client\C\Client name\2013\Test File\Test Name\TEST5\List\[filename.xls]test'!$H$60

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    Welcome to the Forum tmw2912! And howdy, neighbor!

    The problem with what you need to do is that when you build an external reference with a formula, you need to use the INDIRECT function. And the INDIRECT function requires external files to be open, or the reference gives an error. For example, you want this:

    =INDIRECT("'W:\Client\C\Client name\2013\Test File\Test Name\" & B2 & "\List\[filename.xls]test'!$H$60")

    but it won't work unless the file is open.

    The only option for an external reference to a closed file is macros (VBA). There are two ways to do it. The first is to use a VBA function instead of INDIRECT. There is an add-in for this called INDIRECT.EXT floating around the web, and also other similar solutions. The second way is to use VBA to update the formula in G7 whenever the content of B2 changes.

    I happen to like the second one a little better for your particular case, because it's a little simpler to implement but if your formula changes the code has to be updated. Let me know if you want to go down this road. If you attach your file I can install the code for you.

    You said "one value"--do you really just have one formula like this, or more?
    Last edited by 6StringJazzer; 08-09-2013 at 01:33 PM. Reason: added blue text
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-09-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    I really appreciate it. I believe it is one value. with a dependency to that field that will be dynamic.
    Attached Files Attached Files

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    Which cell has the folder name?

  5. #5
    Registered User
    Join Date
    08-09-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    It is in L7

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    Hmm. I deduced it was B2 based on your original post. There's nothing in L7. B2 has "07-July" and the path name in G7 has a folder called "07-July" so I'm going with B2.

    Here's the solution. Macros must be enabled. Whenever B2 changes, the formula in G7 is updated. If the file in the updated path does not exist, Excel will put up the File Open dialog to allow you to find it.

  7. #7
    Registered User
    Join Date
    08-09-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    You are the best!!! Thanks

  8. #8
    Registered User
    Join Date
    08-09-2013
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    Just a question regarding this, and anyone can reply. How do I see the formula or function that is running. I would like to learn from what you did so I know how to do it in the future.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Updating a link in a file extension dynamically based on a field in that spreadsheet

    You need to enter the world of VBA. From Excel, open the VBA development window by pressing ALT-F11. On the left is a a hierarchy that lists open Excel files, and under each Excel file it lists VBA modules under a folder called "Microsoft Excel Objects". Each of the objects listed underneath is a module which can contain code. Every Excel workbook by default has one module for each worksheet (Sheet1, Sheet2, etc.), plus one module for ThisWorkbook. You can also add new modules that get default names like Module1, Module2, etc.

    Find your file in that list, and look at the module named for the worksheet named July, which is the only sheet in your book. Double click on it and you can see the code in the window on the right. It's a bit of a leap to go from not knowing VBA or programming to understanding how all this works. There are many resources available paid and free for learning about VBA. I don't want to try to teach a course in this thread but I can answer specific questions.

+ 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. VBA for Updating Cell validation dynamically based on the RadioButton Selection
    By Rem0ram in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-24-2012, 03:14 PM
  2. Dynamically Updating Chart - Multiple Series based on Advanced Filter
    By alexbell2 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 11-12-2012, 06:52 AM
  3. Replies: 1
    Last Post: 08-15-2008, 07:15 AM
  4. [SOLVED] updating a spreadsheet in 1 field w/ out changing values in anoth
    By rmbpjw in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-13-2006, 10:10 PM
  5. [SOLVED] Cannot download exel spreadsheet file with extension type xls
    By Andrew Robichaud in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-21-2006, 08:30 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