+ Reply to Thread
Results 1 to 9 of 9

VLookup Error

  1. #1
    Registered User
    Join Date
    09-07-2008
    Location
    Cheltenham England
    Posts
    4

    VLookup Error

    Hi All
    I have created a Vlookup formula but i am getting some errors in the string.
    How can i get the formula to display all the values and data in the string? The error occurs when i select London Regional,Newport, or Peterborough in the relevant cell. See formula below:

    =IF(A35="Belfast","2064203",IF(A35="Durham","2074203",IF(A35="Glasgow","2054203",IF(A35="GRO","Nil",IF(A35="ION","5004209",IF(A35="Liverpool","2024203",IF(A35="London HQ","5004203",IF(A35="London Regional","5004211",)*IF(A35="Newport","2044203",)*IF(A35="Peterborough","2034203"))))))))

    Where am I going wrong with the formula? Hope someone can help

    Andy
    Last edited by baffour; 09-07-2008 at 11:02 AM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Two many if's.

    Your better off setting up a table and doing a vlookup

    If you must use if's you could try

    =IF(A35="Belfast","2064203","")&IF(A35="Durham","2074203","")&IF(A35="Glasgow","2054203","")&IF(A35="GRO","Nil","")&IF(A35="ION","5004209","")&IF(A35="Liverpool","2024203","")&IF(A35="London HQ","5004203","")&IF(A35="London Regional","5004211","")&IF(A35="Newport","2044203","")&IF(A35="Peterborough","2034203","")
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    Please Login or Register  to view this content.
    thats it seven nested ifs
    to carry on
    Please Login or Register  to view this content.
    where aa36 can be any cell you want
    to use v lookup which this isnt put them in two adjacent colums on
    "places" in one values in the other

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Hold on now, these "if" solutions are perfectly OK, but I really think the point "this is a bad way of doing this" is a little more important(?)

    You say "I've made a lookup", but you haven't you've made an enormous nested if formula...

    Posting a tiny example of a vlookup to help illustrate what a lookup really is! (The index match eqvuialent is not really relevant, this is something of a generic example)

    HTH
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-07-2008
    Location
    Cheltenham England
    Posts
    4

    VLookup Error

    Thanks for the reply folks. As suggested how do i set up a Vlookup formula using a table? The returned data and cell references will remain the same.

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See Cheeky Charlie example

    or using your data

    VBA Noob
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Hi Baffour,

    how do i set up a Vlookup formula using a table
    To be fair, any answer to this question would basically be a copy-paste of the help section for "vlookup".

    Look at my example, look at the formula in the highlighted cell, then type vlookup into the help search box. That should be plenty to work it out with, and you'll then be filled with a warm, fuzzy, I-worked-it-out feeling.

    Which is nice.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I recommend CC's VLOOKUP. It's easy to maintain, and the table can be put in an out-of-the-way place -- chances are, with some other lookup tables.

    There are usually several ways to do something in Excel.

    =LOOKUP(A35, {"Belfast","Durham","Glasgow","GRO","ION","Liverpool","London HQ","London Regional","Newport","Peterborough"},
    {"2064203","2074203","2054203","Nil","5004209","2024203","5004203","5004211","2044203","2034203"})


    A35 is matched in the first list, and the value in the corresponding position in the second list is returned. The values in the first list must be in ascending order.

    Here's a way to embed the lookup table in the formula. It's exactly equivalent to CC's suggestion, but harder to maintain. The False argument requires an exact match, allowing the items to be in any order:

    =VLOOKUP(A35, {"Belfast",2064203;"Durham",2074203;"Glasgow",2054203;"GRO","Nil";"ION",5004209;
    "Liverpool",2024203;"London HQ",5004203;"London Regional",5004211;"Newport",2044203;"Peterborough",2034203}, 2, FALSE)


    The commas in the list are column breaks, and the semicolons are row breaks.
    Last edited by shg; 09-07-2008 at 02:23 PM.

  9. #9
    Registered User
    Join Date
    09-07-2008
    Location
    Cheltenham England
    Posts
    4

    VLookup Error

    Thanks folks that was really useful. I have picked up a few new things yippie that has just made my day.

+ 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. Vlookup error
    By shahcu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2008, 12:23 AM
  2. Vlookup using two columns-needs to match the first two column
    By pduubb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-01-2008, 01:21 PM
  3. Vlookup Ref error
    By jessa_lee in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-29-2008, 03:21 PM
  4. Vlookup Error
    By jat82nd in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-25-2007, 06:25 PM
  5. Vlookup error
    By svincent in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-09-2006, 08:29 AM

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