+ Reply to Thread
Results 1 to 4 of 4

Can you create a UDF to do a Vlookup to another file

  1. #1
    Registered User
    Join Date
    07-01-2020
    Location
    Nahville TN
    MS-Off Ver
    Office365
    Posts
    2

    Post Can you create a UDF to do a Vlookup to another file

    I am constantly having to do a vlookup to find out the location name for a location number that is in the file I am working with. I have saved the vlookup formula on a stickie and just copy and paste it, but figured there has to be easier way to do this. I thought about a udf where I could just put "=locationname(A1)" where A1 has the item to be looked up and it would return the location name.

    Is there an easier way to do this? There are several instances of these type situations that would make life easier if I could find a way to do.

    Thanks in advance for your help.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can you create a UDF to do a Vlookup to another file

    I don't understand why you would want to create a UDF when the standard VLOOKUP() is perfecty capable of looking up a value from one workbook in a second workbook. However upload the two workbooks in question, or a cut down copy and no doubt we can sort something out.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    07-01-2020
    Location
    Nahville TN
    MS-Off Ver
    Office365
    Posts
    2

    Re: Can you create a UDF to do a Vlookup to another file

    The reason is that instead of having to type the formula along with the path name and other stuff for the vlookup function, doing a locationname(a1) is lot easier...I dont want to have to open the other file all the time. I have to do this type of thing multiple times every day
    Attached Files Attached Files

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can you create a UDF to do a Vlookup to another file

    So that I can be clear. Are you saying that in the 'example vlookup file' you want to be able to enter

    ='some udf name'(A1)

    instead of the longer
    =VLOOKUP(A1,'[example list.xlsx]Sheet1'!$A$1:$B$6,2,0)

    i.e. you're simply wanting to reduce the typing effort.

    In which case I don't see that a UDF offers any advantage over a standard function, and UDF's of course have their own limitations.

    It seems to me this boils down to creating the VLOOKUP formula in the simplest way, and a simple macro attached to either a button you click or a sheet event macro - perhaps one that reacts to a new entry of a code would be the most straightforward.

    The attached uses the following macro which will populate the city when you enter the city ref. in column A

    Another option of course would be to hold the master VLOOKUP formula somewhere and have the macro copy and paste it

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Richard Buttrey; 07-02-2020 at 06:47 AM.

+ 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] Create File Folder from list & create file with header row in each
    By 3345james in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-15-2018, 05:43 AM
  2. Replies: 2
    Last Post: 02-06-2017, 10:11 AM
  3. Replies: 0
    Last Post: 02-03-2017, 11:46 AM
  4. Replies: 0
    Last Post: 02-03-2017, 10:50 AM
  5. Replies: 3
    Last Post: 09-30-2011, 04:35 AM
  6. Create Check List to Delete Columns and Create New File
    By margetc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2011, 05:03 PM
  7. Macro: open file, read data, create table, vlookup
    By doctorspears in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2011, 12:54 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