+ Reply to Thread
Results 1 to 6 of 6

Code to search for address via Name

  1. #1
    Registered User
    Join Date
    06-10-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    37

    Code to search for address via Name

    Hey guys! Love the help you guys have been able to give me so far troubleshooting my code, great site overall.

    I have another problem I'm trying to solve, where I have a big list of customer names and addresses (addresses adjacent to names in columns). I have created a dropdown list (Data validation) with all the names, and I would like to be able to select the one I want, and to return the address in two lines below it, the first for street, the second for City, State, and Zip.
    123456.png
    My Name box is named "NAME_SEARCH" , first address line "ADDRESS_RET_L1" and second address line "ADDRESS_RET_L2"

    What would be the easiest way for me to get this done?

    Thanks!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Code to search for address via Name

    Use a VLOOKUP formula like this in the cell ADDRESS_RET_L1

    =VLOOKUP(NAME_SEARCH,Data!A:C,2,False)

    Use a VLOOKUP formula like this in the cell ADDRESS_RET_L2

    =VLOOKUP(NAME_SEARCH,Data!A:C,3,False)

    where your big list is in columns A to C of sheet Data
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    06-10-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    37

    Re: Code to search for address via Name

    Thank you!
    One more question, is there any chance for me to do this, while keeping the list in a separate workbook? Right now the addresses are in a separate sheet, but could I have them in a different excel file, as to keep my main one from taking up so much space?

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Code to search for address via Name

    Of course - just reference the other workbook (have it open) when you create the formula, then close the big workbook and the formula will include the folder path to your list file.

  5. #5
    Registered User
    Join Date
    06-10-2015
    Location
    USA
    MS-Off Ver
    2013
    Posts
    37

    Re: Code to search for address via Name

    Ok, so I have "=VLOOKUP(NAME_SEARCH,[Book1.xlsx]CUST_ADDRESS_2!$C$2,2,FALSE)" in there, for ADDRESS_RET_L1, and it's giving me a #value! error, any idea why this might be? The second line is giving me the same error, I have "=VLOOKUP(NAME_SEARCH,[Book1.xlsx]CUST_ADDRESS_2!$D$2+[Book1.xlsx]CUST_ADDRESS_2!$E$2+[Book1.xlsx]CUST_ADDRESS_2!$F$2,FALSE)" in that one, since I want to string together a few different columns. I don't see a reason why these don't work, besides mabye the "+"s in the second one, should those be (" & ")?
    "

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Code to search for address via Name

    VLOOKUP is value first, then the range to match against, and the column # from the range to extract the data from.

    So, this formula

    =VLOOKUP(NAME_SEARCH,[Book1.xlsx]CUST_ADDRESS_2!$C$2,2,FALSE)

    should be this, to return the value from column D, where the value in column C matches Name_Search:

    =VLOOKUP(NAME_SEARCH,[Book1.xlsx]CUST_ADDRESS_2!$C:$D,2,FALSE)

    and

    =VLOOKUP(NAME_SEARCH,[Book1.xlsx]CUST_ADDRESS_2!$D$2+[Book1.xlsx]CUST_ADDRESS_2!$E$2+[Book1.xlsx]CUST_ADDRESS_2!$F$2,FALSE)

    should be, probably, along the lines of

    =VLOOKUP(NAME_SEARCH,[Book1.xlsx]CUST_ADDRESS_2!$C:$F,3,FALSE)

    where column C has the names....

+ 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. VBA Code - Search text & search number & search qty and result - Urgent Please
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2014, 10:51 AM
  2. Replies: 1
    Last Post: 03-08-2012, 01:57 PM
  3. Replies: 3
    Last Post: 07-27-2011, 02:29 PM
  4. Search row and return cell address
    By cfaull in forum Excel General
    Replies: 6
    Last Post: 03-12-2011, 02:39 AM
  5. Search by address
    By tombrown39 in forum Excel - New Users/Basics
    Replies: 14
    Last Post: 01-20-2010, 01:25 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