We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide

Excel Code Query

Hi All,

What does the following piece of code mean? I understand it so far as it's matching the value in the current tab with the value in tab "Tab Name" cell A and returning what is in cell C. However I'm confused as to what the "3" and "FALSE" relate to, any help would be great?

=VLOOKUP(W5,'Tab Name'!A:C,3,FALSE)

Thanks

Comments

  • bod1467
    bod1467 Posts: 15,214 Forumite
    edited 3 September 2013 at 9:56AM
    VLOOKUP is a function that allows you to search a table/array for a value, then return an associated cell value.

    W5 = the cell reference for what you are looking for
    'Tab Name'!A:C = the table/array - in this case all rows of columns A to C are selected (W5 is looked for in column 1 ... A in this case)
    3 = the 3rd column of that array ... C in this case
    FALSE = only return a value if there is an exact match in column 1, else return #N/A. TRUE would mean return a value if there is a close match.

    Let's say W5 = "Joe" and "Joe" is contained in cell A10, the function would return the value of cell C10.

    VLOOKUP can be a very powerful tool - I use it quite a lot. :)
  • bod1467 wrote: »
    VLOOKUP is a function that allows you to search a table/array for a value, then return an associated cell value.

    W5 = the cell reference for what you are looking for
    'Tab Name'!A:C = the table/array - in this case all rows of columns A to C are selected (W5 is looked for in column 1 ... A in this case)
    3 = the 3rd column of that array ... C in this case
    FALSE = only return a value if there is an exact match in column 1, else return #N/A. TRUE would mean return a value if there is a close match.

    Let's say W5 = "Joe" and "Joe" is contained in cell A10, the function would return the value of cell C10.

    Brilliant that makes sense, if the table had four columns then I presume the "3" would be a "4"?
  • bod1467
    bod1467 Posts: 15,214 Forumite
    Yes - if it was the 4th column entry you wanted to find. It could still be 3 too. :)

    The number can be anywhere between 1 (although that would be pointless) and the highest column number in the table/array. It all depends on which column of data you want to return info from.
  • Brilliant that makes sense, if the table had four columns then I presume the "3" would be a "4"?

    Not exactly, the number is simply the column that you want it returned from so if it had 20 columns but you only wanted the data from column 3 you'd still enter 3 as the column number even though the table has more columns.

    Also remember vlookup only returns the first row it finds with a match. If there are multiple matches it'll return the first in the order they are listed into the table.
  • Not exactly, the number is simply the column that you want it returned from so if it had 20 columns but you only wanted the data from column 3 you'd still enter 3 as the column number even though the table has more columns.

    Also remember vlookup only returns the first row it finds with a match. If there are multiple matches it'll return the first in the order they are listed into the table.

    That second point was my next question; is there a way around multiple entries?
  • Not using vlookup, you need to use an array function for that sort of thing. See http://office.microsoft.com/en-gb/excel-help/how-to-look-up-a-value-in-a-list-and-return-multiple-corresponding-values-HA001226038.aspx for examples

    It also depends on what you are really trying to do. Spreadsheets and their pivot tables are powerful things but there is a limit to their intended scope and you may be looking at things more suited to a database if you are wanting to bring back multiple rows.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 353.5K Banking & Borrowing
  • 254.1K Reduce Debt & Boost Income
  • 455K Spending & Discounts
  • 246.6K Work, Benefits & Business
  • 602.9K Mortgages, Homes & Bills
  • 178K Life & Family
  • 260.5K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.