+ Reply to Thread
Results 1 to 7 of 7

vlookup codes - multiple sheets

  1. #1
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    vlookup codes - multiple sheets

    I use excel 2003 and sometimes 2010 so my solutions have to run on both.

    Im getting n/a errors when i use vlookup to search another sheet for values.

    I put my data in a sheet called 'data' and then search postcodes which are stored in 3 other sheets named pcode1, pcode2, pcode3.

    I use the vlookup to attach the following to each postcode: Constituency Name, Ward Name, Westminster Name, Council Area Name, SP Region.

    An example would be:
    =VLOOKUP(B2,pcode1!$A$2:$I$65001,5,FALSE)

    where B2 is the postcode
    pcode1 is the first sheet with 65000 postcodes
    column 5 has the constituency name, col 6 the ward name, col 7 the ward name, col 8 westminster name and so on.

    Ive attached an example sheet.

    How do i write a vlookup macro to search across all three sheets (pcode1, pcode2, pcode3), infilling the 5 fields next to each postcode (and most importantly while avoiding the dreaded n/a erorrs)?
    Attached Files Attached Files
    Last edited by intothewild; 02-27-2012 at 05:34 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: vlookup codes - multiple sheets

    You shouldn't need a macro... In C4 try this formula:

    Please Login or Register  to view this content.
    copied down and across.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: vlookup codes - multiple sheets

    perfect it works for me thanks!

    when i swiped the forumla down on my 'big sheet' with 'all' the postcodes i noticed that the formula didnt catch some of them.
    the reason wasnt the forumla itself, it was because i had either leading or trailing whitespace
    any ideas how to remove this without deleting parts of the postcodes themselves?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: vlookup codes - multiple sheets

    The easiest way would be to make a new column with formula like =TRIM(A2) copied down.. then you can copy and paste special the column over the original and delete the formula column.

  5. #5
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: vlookup codes - multiple sheets

    thanks!

    last question..

    .. how does the formula work? i can adapt it and use it no problrm, i also get the match() part, but the if(isnumber and index bits have me a little puzzled.
    Last edited by intothewild; 02-27-2012 at 05:37 PM.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: vlookup codes - multiple sheets

    Match() returns a numeric position if a match is found and a #N/A! error if not found.... ISNUMBER() simply checks if a number was returned by the MATCH() function, so that if it was, we know there was a match. INDEX() simply indexes the range where the desired return data is and once the MATCH() position is found, then item in the same relative position from the INDEXed array is returned. Here is more on INDEX/MATCH

  7. #7
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: vlookup codes - multiple sheets

    great link, ill get stuck into that just now...thanks NBVC!

+ 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