+ Reply to Thread
Results 1 to 7 of 7

Refer to Excel workbook by path, based on cell value data

  1. #1
    Registered User
    Join Date
    12-26-2014
    Location
    Florida
    MS-Off Ver
    2013
    Posts
    3

    Refer to Excel workbook by path, based on cell value data

    Hi everyone. New to the forum. Thanks in advance for your assistance.

    I have stock price data downloaded in individual .xls files titled by Symbol (just 2 columns - Date & Close). I would like to be able to INDEX MATCH or VLOOKUP closing prices on a certain date using a file path, with the path capable of being adapted when I type in a new symbol and/or date. I have attached the layout I had in mind. I was able to use an index formula to grab the data, however with the enormous amount of stocks/mutual funds out there, it seems improbable to type the file name into every formula. If someone feels that vba would be more productive, I'm open to it (although my experience is limited). Thanks again.

    Stockdata.xlsx

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,858

    Re: Refer to Excel workbook by path, based on cell value data

    This may be an easier solution. The following UDF will give you stock price for a stock and a particular date. No need to store that data yourself when you can get the data as needed from the internet.

    The syntax is =StockQuote(Range for Symbol, Range for date), ie. = StockQuote(A1,B1) where A1 contains the symbol and B1 contains the date.

    I did not develop this code, but do not remember where I got it. I use it regularly.

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    12-26-2014
    Location
    Florida
    MS-Off Ver
    2013
    Posts
    3

    Re: Refer to Excel workbook by path, based on cell value data

    Thanks for the quick response. I will admit that VBA is not something I've spent much time with. I've copied the code to Sheet 1 tab (selected View Code). Then entered a stock symbol in A1 and a date in B1 and entered the formula in B2. It resulted in the #Name? error. Any suggestions for a rookie?

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Refer to Excel workbook by path, based on cell value data

    Sounds like you put the code in the wrong location.

    It should go into a general module. One way to get there:

    Right click the sheet tab>View Code

    Goto the Insert menu>Module
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    12-26-2014
    Location
    Florida
    MS-Off Ver
    2013
    Posts
    3

    Re: Refer to Excel workbook by path, based on cell value data

    Got it working. This is exactly what I was looking for. Thanks much.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Refer to Excel workbook by path, based on cell value data

    You're welcome. We appreciate the feedback!

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,858

    Re: Refer to Excel workbook by path, based on cell value data

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Refer Indirectly to File Path
    By Apokolips in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-03-2014, 06:44 PM
  2. Refer Indirectly to File Path
    By Apokolips in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2014, 01:20 AM
  3. Excel 2011 0n Mac If cell value is 0 I do not want to print 0 on cells that refer to data
    By badgershalt in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 06-18-2013, 02:33 PM
  4. Use cell in open workbook to id path to wanted data
    By NickiName in forum Excel General
    Replies: 3
    Last Post: 05-10-2007, 02:04 PM
  5. When writing a macro in excel workbook, how do I refer to ea cell
    By Diana Bartz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2005, 05:05 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