+ Reply to Thread
Results 1 to 14 of 14

Need to get the name of the File in a Vlookup VBA using wildcard characters

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Need to get the name of the File in a Vlookup VBA using wildcard characters

    Need to get the name of the File in a Vlookup VBA using wildcard characters

    Dear Forum,

    I have to do a VLOOKUP from a specific file which is stored in the same folder as the file in which I need to get this VLOOKUP done, however the name can change anytime keep a word common only for this specific file...
    Ex:
    I have a File called "Mapping as on 8th May" from where i need to lookup some information for my file and I intend to do this using VLOOKUP in VBA in a Module but since the name can change to anything such as"Mapping as on 16th May" I cant use it in the VBA code, so is there a way around this where If I have this file stored in the same folder then I keep the word "Mapping" specific and unique for all other files in the same folder that the search can pull this file name to be further used in my lookup..

    My lookup is very simple as of now and I do not know how to use the wildcards in VLOOKUP lookup range for the file name as the columns are going to remain the same...


    Regards
    e4xcel

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Use GetOpenFilename to navigate to the file and select. Then use the variable in the VLookup. See example in help file.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Thanks but where if the Help File and moreover If I want to avoid the FileOpen Dialog box and jst streamline the filename based on the Uniqueness of the name "Mapping" instead then it would be more easier..

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    where if the Help File
    In the VBE, Type GetOpenFilename, then press F1.

    You'll have to acquire the filename first, then use it in the vlookup.

    It would be easy enough to use the Dir function to get the filename.

    Please Login or Register  to view this content.
    This assumes that there will never be more than one match in the folder.
    Last edited by Tinbendr; 05-18-2014 at 03:04 AM.

  5. #5
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Dear Tinbendr,

    Thanks for the help and the code, however when i tried using it, just dint work, so please advise me what is wrong with my modification ?


    Please Login or Register  to view this content.
    Also what is the variable type for FN$ and why is it written with a "$" sign next to it ?

    Please explain as I am not good in VBA..

    Thanks in advance
    e4excel

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    You need to open the file for Workbooks to work, otherwise you'll get a subscript out of range error.
    If posting code please use code tags, see here.

  7. #7
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    just dint work,
    Your response it too vague to offer any solutions.

    Please post two workbooks to illustrate your situation.

    FN$ stands for filename string. The dollar sign is a shortcut in variable declarations.

    It's tha same as; Dim FN as String.

    Others include:
    ! - Single
    % - Integer
    # - Double
    & - Long
    $ - String
    @ - Currency.

  8. #8
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Dear Tinbendr,

    Thanks a lot for the explanation, I was totally unaware of this short-cut..

    Please find both the files for reference, actually i am not getting any error but neither the answer I am looking for so I am sure I am missing out something..

    Regards
    e4excel
    Attached Files Attached Files

  9. #9
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Thanks a lot Tinbendr, this works however I need to use it for an entire column then how do i use it in this style.

    Please Login or Register  to view this content.


    I liked the approach of finding the File with the path and then close..

    Regards
    e4excel

  11. #11
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Oh!, I didn't realize you just wanted formula on WB1.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    Dear Tinbendr,

    Thanks again , however I would really appreciate if you could tweak just a little more to get the code in this style as for the explanation I had used Rows A2:A4, however in reality I would be having dynamic rows and I therefore would use 2 Variables to include/mark the lastrow range.


    Please Login or Register  to view this content.
    But when i try using this , it does not work....and gives the error Object required...

    Now is it because we cannot have Set properties for different workbooks..

    Please Login or Register  to view this content.

    This works but I am not sure how so can you please help me improve on this code ...
    Thanks again....








    Regards
    e4excel
    Last edited by e4excel; 05-24-2014 at 11:16 AM.

  13. #13
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    OK, time for some clarification!

    WHAT IS THE RESULT YOU WANT?

    Describe what you're trying to accomplish.

    If all you're doing is pulling ages from WB2, based on a value in WB1, then we need to use Find and not vlookup.

  14. #14
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Need to get the name of the File in a Vlookup VBA using wildcard characters

    NO i managed somehow to get what I wanted and thanks to you..

    Thanks once again....

    Just one small query if i had to find a sheet in the same file using wildcard, then what would be the code..

    Regards
    e4excel

+ 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. [SOLVED] wildcard characters
    By Hasty in forum Excel General
    Replies: 2
    Last Post: 07-21-2006, 05:45 AM
  2. [SOLVED] HELP: Wildcard Characters
    By bbddvv in forum Excel General
    Replies: 0
    Last Post: 06-28-2006, 09:40 AM
  3. [SOLVED] WildCard Characters
    By Ralph Heidecke in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-01-2006, 02:45 PM
  4. Using Wildcard characters in sumproduct
    By Charles in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  5. [SOLVED] Using Wildcard characters in sumproduct
    By Charles in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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