+ Reply to Thread
Results 1 to 3 of 3

Using a Variable Filename in a VLOOKUP

  1. #1
    Registered User
    Join Date
    03-26-2014
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    2

    Unhappy Using a Variable Filename in a VLOOKUP

    Hi,

    I'm working on a project where I need to populate a column with vlookups taken from different workbooks, I have for the most part got it working.
    However currently, everytime it populates a cell it prompts the user to select the sheet from the workbook as there are two. The sheet name is always the same so I tried to add it into the code so it would avoid having to repeatedly click okay while it populated the table.

    This is where I'm struggling.

    This is the original code where it asks for the user to select the sheet every time.

    Please Login or Register  to view this content.
    This is what is produced when it is run and the user selects the worksheet each time (which works perfectly fine):

    Please Login or Register  to view this content.

    I tried to enter the Full Costs sheet name into the code like so:

    Please Login or Register  to view this content.
    However this produces the following:

    Please Login or Register  to view this content.
    The issue I have found is that the square brackets that are around the filename are generated automatically, they aren’t in the actual filename and I haven’t put them in, so I am struggling to work out how to add the sheet name in where it wont be included within the square brackets, as that is what's breaking the lookup.

    What am I doing wrong? Any ideas?

    Thanks,
    Matt.
    Last edited by Cpt_Matt; 03-26-2014 at 07:24 AM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Using a Variable Filename in a VLOOKUP

    Add the square brackets into the filename?

  3. #3
    Registered User
    Join Date
    03-26-2014
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Using a Variable Filename in a VLOOKUP

    I can try that now, but I have a feeling it'll still try and automatically generate them, because I've added a close bracket into the code and it still breaks it.
    I'll let you know.

    EDIT: How do I go about adding one in the middle of the string?
    Last edited by Cpt_Matt; 03-26-2014 at 06:39 AM.

  4. #4
    Registered User
    Join Date
    03-26-2014
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Using a Variable Filename in a VLOOKUP

    That worked, thank you.

+ 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. Variable filename in vlookup
    By Lizzietish11 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-19-2016, 08:30 AM
  2. Vlookup From Closed Workbook with variable filename
    By wporter86 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-25-2013, 10:47 AM
  3. Vlookup in a database with variable filename?
    By Alexhoc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-09-2013, 09:27 AM
  4. [SOLVED] Find if filename exists and update variable within the filename structure
    By Lungfish in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-18-2013, 02:42 AM
  5. Replies: 3
    Last Post: 07-09-2012, 03:09 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