+ Reply to Thread
Results 1 to 8 of 8

Having trouble with IF AND OR string

  1. #1
    Registered User
    Join Date
    11-10-2007
    MS-Off Ver
    365
    Posts
    46

    Having trouble with IF AND OR string

    Folks,

    I'm doing something wrong with this forumla:

    =IF(E$21<$H$16,IF(OR(HLOOKUP(E$19,Intg.xlsm!ENDYRAGE,2)>=65,HLOOKUP(E$19,Intg.xlsm!ENDYRAGE,3)>=65),0,1)))

    If E$21 is less than H$16 then I want the formula to evaluate whether either person is at or over 65 if year end. If E$21<H$16 and either person is at or over 65 I want the formula to return 0 otherwise I have another formula to insert. I'm getting FALSE at the moment. I suspect it's associated with the OR statement which I'm not used to using.

    Any help is appreciated!

    Kelly

  2. #2
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Having trouble with IF AND OR string

    No, the FALSE is returned from the first IF (you left the term implicit so it returns boolean by default), it's not even assessing the OR.

    You've also got one-too-many right parens on the end.

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Having trouble with IF AND OR string

    Hope this helps

    =IF(E$21<$H$16,IF(OR(HLOOKUP(E$19,Intg.xlsm!ENDYRAGE,2)>=65,HLOOKUP(E$19,Intg.xlsm!ENDYRAGE,3)>=65),0,1),whattodoifE21isnotlessthanH16goeshere)

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Having trouble with IF AND OR string

    What ben is saying is:

    =IF(E$21<$H$16,IF(OR(HLOOKUP(E$19,Intg.xlsm!ENDYRAGE,2)>=65,HLOOKUP(E$19,Intg.xlsm!ENDYRAGE,3)>=65),0,1),"E$21 is NOT < $H$16")

    TEST
    TEST WAS TRUE
    TEST WAS FALSE


    You are missing the FALSE bit
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  5. #5
    Registered User
    Join Date
    11-10-2007
    MS-Off Ver
    365
    Posts
    46

    Re: Having trouble with IF AND OR string

    How would I write it such that its evaluating the first term (E21<H16) and then looks to see if one of the next two (either one being over 65) is true. If first term and either second or third is true it returns 1 or else 0. I can enter formulas into the 1 or 0?

    Many thanks. My head hurts from banging it on the key board.

    Kelly

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Having trouble with IF AND OR string

    Please Login or Register  to view this content.
    It already does that, but it is only going to evaluate the bolded portion of the formula if E21 is indeed less than H16.

    You can replace the 1 and 0 with further formulas if necessary.

    Just keep in mind, if E21 is NOT less than H16, NONE of the bold tests will happen, it will immediately execute the FALSE statements. (your original formula did not have a statement for FALSE, so it defaulted to the boolean to return FALSE as a value. I added it in red in the formula here and above, you can replace it to whatever you need the formula to do if the original test (E21<H16) comes back FALSE)

  7. #7
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Having trouble with IF AND OR string

    Quote Originally Posted by lc130 View Post
    evaluating the first term (E21<H16) and then looks to see if one of the next two (either one being over 65) is true. If first term and either second or third is true it returns 1 or else 0. I can enter formulas into the 1 or 0?
    You mean something like this?

    Please Login or Register  to view this content.
    1 AND (2 OR 3)

    that kind of logic test?

  8. #8
    Registered User
    Join Date
    11-10-2007
    MS-Off Ver
    365
    Posts
    46

    Re: Having trouble with IF AND OR string

    Yes. If first term is true (E21<H16) then check to see if either of the second two terms are true. If either of those second terms are true (along with the first term) return one value, else, return another value.

    I've never had a very good understanding of these conditional statements.

    Thank you

    Kelly

+ 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] Trouble testing if a string contains numbers only
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-27-2013, 10:03 AM
  2. Trouble extracting numbers from an IP Address String in VBA
    By bigballingpr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-26-2013, 04:35 AM
  3. [SOLVED] Trouble extracting data from a string
    By par71 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-30-2012, 06:04 PM
  4. Having trouble using a string as the name for an array
    By construct in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-08-2012, 10:38 AM
  5. [SOLVED] having trouble writing string to cell-xl2k
    By Terry Carpenter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2005, 02:06 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