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

Another Excel Code Query

Hi All,

What does the following code mean?

It's an old code that seems to be doing what I need it to but I want to try and understand the logic behind it.

=IFERROR(VLOOKUP(A5,'Football Data'!$A$5:$E$42,2,0),0)

Thanks

Comments

  • johnmc
    johnmc Posts: 1,265 Forumite
    VLOOKUP(A5,'Football Data'!$A$5:$E$42,2,0)
    Is looking up a value from A5 on the "Football Data" tab.

    It looks down Column A until it finds the first reference to the search and then brings in the value that's in Column B.

    The "0" is the same as "False", so it will only match an exact value.


    IFERROR(#####,0)
    This looks at the value returned. If there is no value that matches it will show "0" rather than #N/A.
  • Perfect, thanks for that?

    One final point, why does the code need two references to "A5"? There is the A5 before "Football Data" and there is $A$5.

    Thanks again.
  • bossymoo
    bossymoo Posts: 6,924 Forumite
    1,000 Posts Combo Breaker
    A5 is the value on the current sheet that its trying to match against on the football data tab.
    Bossymoo

    Away with the fairies :beer:
  • gb12345
    gb12345 Posts: 3,055 Forumite
    As johnmc says, but just to add that the $A$5:$E$42 in the VLOOKUP means that it will only find a match in rows 5 to 42, so if you ever add extra rows to the Football Data tab you would need to take account of that (either by increasing the 42 or by changing it to $A:$E)
  • Thanks everyone - excellent.
  • JimmyTheWig
    JimmyTheWig Posts: 12,199 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Combo Breaker
    Perfect, thanks for that?

    One final point, why does the code need two references to "A5"? There is the A5 before "Football Data" and there is $A$5.
    The first A5 means the value of A5 in the current spreadsheet. I'm going to stick my neck out and guess this says "Arsenal".
    The second A5 ($A$5:$E$42) is the start of the table in the other tab..

    The cell below this will have A6 as the first argument, but the range will still start from $A$5.
  • The first A5 means the value of A5 in the current spreadsheet. I'm going to stick my neck out and guess this says "Arsenal".
    The second A5 ($A$5:$E$42) is the start of the table in the other tab..

    The cell below this will have A6 as the first argument, but the range will still start from $A$5.

    Arsenal - yes ;)
  • JimmyTheWig
    JimmyTheWig Posts: 12,199 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Combo Breaker
    Arsenal - yes ;)
    And is the table in the "Football Data" tab in alphabetical order, or is that in league position order?
  • jackomdj
    jackomdj Posts: 3,073 Forumite
    Part of the Furniture 1,000 Posts
    Vlookups are great, I use them all the time. But remember they only pick up the first time the same things happen.

    So if you are looking up Arsenal but it is for goals and it is on the football data tab twice it will only give you what is in column b next to the first time it happens.

    Eg

    A 5
    B 2
    C 7
    A 3

    If you are looking up a it would bring back 5 not 8.
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
  • 178.1K Life & Family
  • 260.6K 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.