+ Reply to Thread
Results 1 to 8 of 8

LOOKUP with TRUE/FALSE Values

Hybrid View

  1. #1
    Registered User
    Join Date
    06-13-2019
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 14.3.9
    Posts
    6

    LOOKUP with TRUE/FALSE Values

    Hello,

    I'm trying to use the LOOKUP function to return the header for the last FALSE in an array. Here is an example of the data set:

    A B C D
    1 2019 2018 2017 2016
    2 TRUE FALSE FALSE TRUE
    3 TRUE FALSE TRUE TRUE
    4 TRUE TRUE FALSE TRUE

    The code I'm using in to find the header for the last FALSE value in the second row is:
    =LOOKUP(FALSE,A2:D2,A1:D1)
    I would expect that for each row, the LOOKUP would function return an error because LOOKUP expects data to be sorted in ascending order, the first entry in the lookup array is TRUE, and it's looking for FALSE, but that's not what happens.

    If the first value in the lookup array is TRUE and the second value is FALSE, the function returns the second value in the results array (in this case, 2018). But, if the first and second lookup values are TRUE (like in the fourth row), the LOOKUP function throws an error.

    Can anyone explain to me what's happening? Is there a formula that will give me the year with the last FALSE in each row (so for the second row, it should be 2017, for the third row 2018, and for the fourth row 2017).

    Thank you!
    Last edited by capthollyshort; 06-14-2019 at 12:02 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,790

    Re: LOOKUP with TRUE/FALSE Values

    Welcome to the forum!

    I don't understand how your formula relates to the table. The formula is dealing with columns, yet the table is arranged in rows. If the years are in row 1, then the formula doersn't even cover them.
    Last edited by AliGW; 06-14-2019 at 01:16 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    06-13-2019
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 14.3.9
    Posts
    6

    Re: LOOKUP with TRUE/FALSE Values

    You're absolutely right! I made some changes to the post.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: LOOKUP with TRUE/FALSE Values

    If you want the year for each row, why are you testing the column range, and not the row range?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,994

    Re: LOOKUP with TRUE/FALSE Values

    =index($a$1:$d$1,max(if($a$2:$d$4=false,column($a$1:$d$1))))
    Attached Files Attached Files
    Ben Van Johnson

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: LOOKUP with TRUE/FALSE Values

    Another one
    E2
    =LOOKUP(1,0/NOT(A2:D2),A$1:D$1)

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,790

    Re: LOOKUP with TRUE/FALSE Values

    And another:

    =LOOKUP(2,1/(A2:D2=FALSE),A$1:D$1)

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: LOOKUP with TRUE/FALSE Values

    And another.

    =LOOKUP(2,1/(1-A2:D2),$A$1:$D$1)
    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Simple TRUE/FALSE lookup needed
    By willm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-19-2018, 01:49 PM
  2. Replies: 3
    Last Post: 08-16-2018, 06:07 AM
  3. [SOLVED] True and False Lookup
    By greatdragon in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-08-2017, 08:03 PM
  4. lookup exact match returns TRUE or FALSE
    By quade_1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2016, 02:21 AM
  5. [SOLVED] formula to lookup formatting and return true false
    By paintballlovr in forum Excel General
    Replies: 2
    Last Post: 05-17-2012, 09:32 AM
  6. lookup value - true/false
    By Peter in forum Excel General
    Replies: 3
    Last Post: 05-01-2006, 07:30 PM
  7. Can LooKUP get return value of True or False?
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2005, 07:30 PM

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