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!

Excel Code Query

Cotta
Cotta Posts: 3,667 Forumite
Hi All,

I have the following code in Excel, it basically look for a code and returns a separte value in an accompanying spreadsheet. However in front of this doe I want to include something to reflect that if cell A1 contains the word "Liverpool" then I want the word "Liverpool" returned instead of the below function being carried out. How do I do this?

=VLOOKUP(B2,'Q\Folder\Football\[Codes.xlsx]Sheet1'!$A$1:$G$670,7,FALSE)

Thanks

Comments

  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Changing your formula to the following will probably do it:-

    =if(b2="Liverpool","Liverpool",VLOOKUP(B2,'Q\Folder\Football\[Codes.xlsx]Sheet1'!$A$1:$G$670,7,FALSE))
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • Cotta
    Cotta Posts: 3,667 Forumite
    Perfect - thanks.
  • Mirno
    Mirno Posts: 219 Forumite
    What do you mean by "contains" - if you mean that it exactly matches then rmg1's code is perfect. If you mean that it should also match "Liverpool FC", or "I hear Liverpool are rubbish" then:

    IF(ISERR(FIND("Liverpool", B2)), LOOKUP..., "Liverpool")

    Will find the substring "Liverpool" anywhere within B2.

    Mirno
  • EchoLocation
    EchoLocation Posts: 901 Forumite
    Part of the Furniture 500 Posts Combo Breaker
    Mirno wrote: »
    What do you mean by "contains" - if you mean that it exactly matches then rmg1's code is perfect. If you mean that it should also match "Liverpool FC", or "I hear Liverpool are rubbish" then:

    IF(ISERR(FIND("Liverpool", B2)), LOOKUP..., "Liverpool")

    Will find the substring "Liverpool" anywhere within B2.

    Mirno

    Could also use SEARCH, as FIND is case sensitive.
  • Cotta
    Cotta Posts: 3,667 Forumite
    Mirno wrote: »
    What do you mean by "contains" - if you mean that it exactly matches then rmg1's code is perfect. If you mean that it should also match "Liverpool FC", or "I hear Liverpool are rubbish" then:

    IF(ISERR(FIND("Liverpool", B2)), LOOKUP..., "Liverpool")

    Will find the substring "Liverpool" anywhere within B2.

    Mirno

    Hey, less of the Liverpool are rubbish :)

    Thanks to all for your feedback.
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
  • 352.2K Banking & Borrowing
  • 253.6K Reduce Debt & Boost Income
  • 454.3K Spending & Discounts
  • 245.3K Work, Benefits & Business
  • 600.9K Mortgages, Homes & Bills
  • 177.5K Life & Family
  • 259.1K 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.