+ Reply to Thread
Results 1 to 6 of 6

IF / AND Error

Hybrid View

  1. #1
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    IF / AND Error

    .
    I am trying to use multiple IF / AND in a formula. Having searched the NET I don't find anything (yet) that shows how and I don't see anything that says it can't be done. ??

    Here is the start of my goal:

    =IF(AND(C5<26%,C5>24%),"25%",""),IF(AND(C5<51%,C5>49%),"50%","")

    The final goal is to check C5 for 25%, 50%, 75% and 100%.

    Because the percentage will never be exactly a whole number, it needs to check for < and > to narrow down a percentage range.



    Can I use multiple IF / AND statements in the formula ? If yes, how ? If no, what approach is required ?


    Formula Guru's ??

  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. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,068

    Re: IF / AND Error

    This approach:

    =IF(AND(C5<26%,C5>24%),"25%",IF(AND(C5<51%,C5>49%),"50%",IF(AND(C5<?%,C5>?%),"75%",AND(C5<?%,C5>?%),"100%",""))))
    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
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: IF / AND Error

    You can use AND with IF.

    Something like this:

    =IF(AND(C5<0.26,C5>0.24),0.25,IF(AND(C5<0.51,C5>0.49),0.50,...

    That being said, I would use MROUND:

    =MROUND(C5,0.25)

    Edit: I withdraw the MROUND suggestion. That would round a value even if it is outside of the range that you want to check.
    Last edited by 63falcondude; 09-29-2017 at 01:44 PM.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: IF / AND Error

    .
    Thank you all for responding so quickly ! Wonderful resources !!!!

    Ali ... edited your formula at end to this :
    =IF(AND(C5<26%,C5>24%),"25%",IF(AND(C5<51%,C5>49%),"50%",IF(AND(C5<76%,C5>74%),"75%",IF(AND(C5=100%),"100%",""))))
    Had to use that last "IF / AND" for it to work correctly.

    Thank you all so much again.



  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: IF / AND Error

    Just for the fun of it, here's another option:

    =IF(ABS(MROUND(C5,0.25)-C5)<0.01,MROUND(C5,0.25),"")

  6. #6
    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. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,068

    Re: IF / AND Error

    Glad to have helped. The formula I gave was not intended to be the final formula, it was just showing you how to build yours. Happy you got there!

+ 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. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  2. [SOLVED] Run-tim error -2147467259(80004005): Automation error Unspecidied error
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2014, 12:12 PM
  3. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  4. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  5. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  6. Error 75 File/Path access error, sometimes Error 1004
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-16-2011, 02:35 PM
  7. Error Handling - On Error GoTo doesn't trap error successfully
    By David in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2006, 02:10 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