+ Reply to Thread
Results 1 to 5 of 5

VBA to change file path based on cell value

  1. #1
    Registered User
    Join Date
    10-20-2015
    Location
    Alabama
    MS-Off Ver
    Excel 2013
    Posts
    29

    VBA to change file path based on cell value

    I am attempting to save a lot of my time by trying to pull data from hundreds of different workbooks all within the same directory; the name of each workbook is in included in its own column in my lookup sheet. I already have enough data consolidated to where I can use an INDEX-MATCH to pull the required data, but the problem I'm running into is having to change the source file name within the formula every time the source file changes. Could a code be created that changes the source file name based on a cell value? Current formula listed first; file path and other references obviously changed. The source file name is located in the A column. The second formula is my desired result, although I know the formula will not work as such.

    =INDEX('C:\Folder1\Products\[Product1.xlsx]Data'!$M$4,MATCH($L$1,''C:\Folder1\Products\[Product1.xlsx]Data'!$M$3,0))
    =INDEX('C:\Folder1\Products\[$A3.xlsx]Data'!$M$4,MATCH($L$1,''C:\Folder1\Products\[$A3.xlsx]Data'!$M$3,0))

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to change file path based on cell value

    Hi there,

    This is very difficult to test without access to your workbook and your directory structure, but you could try:
    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    10-20-2015
    Location
    Alabama
    MS-Off Ver
    Excel 2013
    Posts
    29

    Re: VBA to change file path based on cell value

    Quote Originally Posted by Greg M View Post
    Hi there,

    This is very difficult to test without access to your workbook and your directory structure, but you could try:
    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Greg,
    I apologize for the late reply. Unfortunately, this does not work either. I removed the spaces and "&" but still nothing. The most it would do is before I removed anything; it would bring up a file path in a new window for me the choose the correct path. I attempted to create a VBA that copies the file name to the formula for every cell, but I had no success creating that either.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-20-2015
    Location
    Alabama
    MS-Off Ver
    Excel 2013
    Posts
    29

    Re: VBA to change file path based on cell value

    Please Login or Register  to view this content.
    I found this code for saving a file with its name coming from a cell value within the workbook. Could this be a springboard for a lookup value from a file name based on cell value?

    Also, does Excel not recognize a file path as text? I did a combination of the FIND and T functions and the result was always a blank, which means I either formulated it wrong or the path is not recognized as text. If it's not recognized as text, then I'm not sure any formula could be used to change it based on cell value. It would have to be VBA.
    Last edited by TitansGo; 10-13-2016 at 04:26 PM.

  5. #5
    Registered User
    Join Date
    10-20-2015
    Location
    Alabama
    MS-Off Ver
    Excel 2013
    Posts
    29

    Re: VBA to change file path based on cell value

    Anyone care to take a shot at this?

+ 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. Need to play a wav file based on path and filename in a selected cell using macro: SOLVED!
    By needtoregistersux in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-31-2016, 07:47 PM
  2. change path for save location based upon text in a cell
    By wardy212 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2016, 08:34 AM
  3. Saving Excel File/Path Based On Cell Value
    By jeremyfraley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2015, 06:00 PM
  4. [SOLVED] Change file path name in VBA code based on files location
    By klunker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2014, 04:08 PM
  5. [SOLVED] VBA code to diplay a file path in a cell based on another cell value
    By zhb12810 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2012, 03:24 PM
  6. Rename and save file to path based on cell info
    By cabinetguy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2010, 12:38 PM
  7. Change file path in formulas for every cell in a sheet
    By jackthefork in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-15-2009, 12:22 PM

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