+ Reply to Thread
Results 1 to 3 of 3

If cells values within a range match then return one value if not return another

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Scotland
    MS-Off Ver
    Excel 2010
    Posts
    84

    If cells values within a range match then return one value if not return another

    Looking to create a formula:

    If 2 cells within range A45:D45 are the same value then VLOOKUP(A45,$B3:$E45,20,FALSE) otherwise VLOOKUP(A45,$B3:$E45,3,FALSE). The problem I have is that the value could be anything.

    Can anyone help.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: If cells values within a range match then return one value if not return another

    Try

    =IF(OR(COUNTIF(A45:D45,A45)>1,COUNTIF(A45:D45,B45)>1,COUNTIF(A45:D45,C45)>1,COUNTIF(A45:D45,D45)>1),VLOOKUP(A45,$B3:$E45,20,FALSE),VLOOKUP(A45,$B3:$E45,3,FALSE))
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,737

    Re: If cells values within a range match then return one value if not return another

    You could try something like this:

    =if(countif(A45:D45,A45)=2,VLOOKUP(A45,$B3:$E45,20,FALSE),VLOOKUP(A45,$B3:$E45,3,FALSE))

    but that will only check for 2 cells being the same as A45, and it is not clear if that is what you want. If you are looking for any 2 cells in A45:D45 being the same, then you could try this:

    =if(OR(countif(A45:D45,A45)=2,countif(B45:D45,B45)=2,countif(C45:D45,C45)=2),VLOOKUP(A45,$B3:$E45,20,FALSE),VLOOKUP(A45,$B3:$E45,3,FALSE))

    If that isn't what you need, then please try to describe your requirements more clearly.

    Hope this helps.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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