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 Logic

Hi,


I had some trouble yesterday with Excel coding and I received various amounts of help on here. After much trial and error I finally got the code to work, however it doesn't make complete sense. Can someone explain the logic to the following code please?


=IF(RIGHT('tab2'!G2,4)="2016",VLOOKUP(A30,'tab2'!A:IY,MATCH($P$29,'tab2'!$1:$1,0),0),VLOOKUP(A30,'tab2'!A:IY,MATCH(tab1!$P$28,'tab2'!$1:$1,0),0))

Comments

  • bengalknights
    bengalknights Posts: 5,022 Forumite
    Part of the Furniture 1,000 Posts
    It says if the right 4 characters on tab2 are equal to 2016 then run a vlookup and match it to p29 tab2 and if not match to p28
  • bod1467
    bod1467 Posts: 15,214 Forumite
    And why did you need a NEW thread about the exact same thing? (How many threads is this now about the same "project"?)

    All the poster above has done is give the same basic explanation that I gave you in the other thread. (The VLOOKUP/MATCH formula was explained to you in your first thread).
  • Cotta
    Cotta Posts: 3,667 Forumite
    Can I ask why the second ",0)" is used after each VLookup? You already used this once within the initial lookup.
  • bod1467
    bod1467 Posts: 15,214 Forumite
    edited 2 August 2016 at 1:05PM
    VLOOKUP has 4 parameters ... Search Term, Source Array, Column Number, True/False

    The ,0) is the True/False parameter ... 0 = FALSE

    The same VLOOKUP formula is needed in each part of the IF command, one to return P29 match, and the other to return P28 match.

    Of course there may be a more elegant way of achieving what the OP is seeking - feel free to advise on this. :)
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.