+ Reply to Thread
Results 1 to 4 of 4

How to use a cells value in a filename (VBA)

  1. #1
    Registered User
    Join Date
    07-04-2011
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2003
    Posts
    7

    Post How to use a cells value in a filename (VBA)

    I was wondering if it is possible to use a value that the user inputs into a cell, in a filename for linking to another spreadsheet in VBA.

    For example, if the user enters "C-11838" in cell B4, I want to be able to set the forumla in C4 to ='K:\GMG\Nets on Floor\Finished Nets\[C-11838.xlsm]Net Summary'!$B$4

    I can't figure out how to set it up so that the number before .xlsm can be a variable.

    Any help would be greatly appreciated!
    Last edited by Greg_2; 07-14-2011 at 09:03 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: How to use a cells value in a filename (VBA)

    Hi,

    Try:

    =INDIRECT("'K:\GMG\Nets on Floor\Finished Nets\["&C4&".xlsm]Net Summary'!$B$4")

    INDIRECT will not work if the other file isn't open though although I think you can install the MoreFunc add-in and use INDIRECT.EXT

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    07-04-2011
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How to use a cells value in a filename (VBA)

    Thanks! It works like a charm when the file is open, though I was hoping there was a way to do this without the file being open.

    The ultimate goal of this tool is so that a manager can enter in multiple tag numbers, and have all the values in B4 returned from each file, without them having to open each individual file.

    Edit: I'm looking into MoreFunc.
    Last edited by Greg_2; 07-14-2011 at 08:50 AM.

  4. #4
    Registered User
    Join Date
    07-04-2011
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How to use a cells value in a filename (VBA)

    MoreFunc Add in works perfectly.

    Thank you for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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