+ Reply to Thread
Results 1 to 7 of 7

Date-intervals in =if(and()) function

  1. #1
    Registered User
    Join Date
    09-16-2019
    Location
    Denmark
    MS-Off Ver
    Excel 2016
    Posts
    13

    Date-intervals in =if(and()) function

    Hallo everybody

    I am trying to use an =if(and()) function to age-distribute a lot of data into different categories depending on the age of the specific data.
    But in trying to do so I get the "Not trying to type a formula"-error.

    I have tried to &"<="& in order to overcome the problem, but that doesnt help; I get the same mistake.

    The formula is as follows:

    =IF(AND(F5>=$B$8;F5<=$C$8;$A$8);IF(AND(F5>=$B$9;F5<=$C$9;$A$9;IF(AND(F5>=$B$10;F5<=$C$10;$A$10;IF(AND(F5>=$B$11;F5<=$C$11;$A$11;IF(AND(F5>=$B$12;F5<=$C$12;$A$12;IF(AND(F5>=$B$13;F5<=$C$13;$A$13;IF(F5<=$B$14;$A$14;"Error"))))))))))))

    What I on the other hand CAN write is:

    =IF(AND(F5>=$B$8;F5<=$C$8;$A$8);IF(AND(F5>=$B$9;F5<=$C$9;$A$9;"Error");"Error")) (Here I get an False, which is fine)

    Anyone who knows whats up with that?

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

    Re: Date-intervals in =if(and()) function

    You seem to have the closed bracket for your AND functions in the wrong place. For instance, the formula should start with:

    =IF(AND(F5>=$B$8;F5<=$C$8);$A$8;IF(AND(F5>=$B$9;F5<=$C$9);$A$9;IF(AND(F5>=$B$10; … and so on.

    Hope this helps.

    Pete

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Date-intervals in =if(and()) function

    No nested IFs required
    just use

    =if(or(f5<b8,f5>b14),"error",index(a8:a14,match(f5,b8:b14,1),1))
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Date-intervals in =if(and()) function

    Pete is correct, however I suspect if the ages are start and end ages
    0-9
    10-20
    21-30

    etc the formula can be simplified as an if statement as many of the terms are redundant as the ifs are nested


    or a simple vlookup will suffice

    https://exceljet.net/formula/group-numbers-with-vlookup

  5. #5
    Registered User
    Join Date
    09-16-2019
    Location
    Denmark
    MS-Off Ver
    Excel 2016
    Posts
    13

    Re: Date-intervals in =if(and()) function

    Hey Pete

    Thanks for the answer!

    It helped a bit, and thank you for that, unforturnaly its not completed.

    I can write the following, where I delete the bracket in the first if(and())-function, but keep the brackets in the remaing if(and())-functions:

    =IF(AND(F5>=$B$8;F5<=$C$8;$A$8);IF(AND(F5>=$B$9;F5<=$C$9);$A$9;IF(AND(F5>=$B$10;F5<=$C$10);$A$10;IF(AND(F5>=$B$11;F5<=$C$11);$A$11;IF(AND(F5>=$B$12;F5<=$C$12);$A$12;IF(AND(F5>=$B$13;F5<=$C$13);$A$13;IF(F5<=$B$14;$A$14;"Fejl"))))))) = "FALSE".

    But actually its supposed to say "5+ years" instead of "False", because the date in F5 is <=$B$14 ("5+ years" is the category that the date is suppose to be distrubuted to according to the formula).

    Any idea why I get "False" instead of "5+ year"?

  6. #6
    Registered User
    Join Date
    09-16-2019
    Location
    Denmark
    MS-Off Ver
    Excel 2016
    Posts
    13

    Re: Date-intervals in =if(and()) function

    Sorry, didnt see the rest of you fellas answers. I am gonna try that.

  7. #7
    Registered User
    Join Date
    09-16-2019
    Location
    Denmark
    MS-Off Ver
    Excel 2016
    Posts
    13

    Re: Date-intervals in =if(and()) function

    Thank you all for the answers.
    I went with Pete_UK's original answer, and it worked very well!

+ 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. Replies: 1
    Last Post: 09-27-2016, 12:41 AM
  2. Time Intervals, Ranges, IF function, Lookup Function
    By HDTV in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-23-2014, 03:52 PM
  3. [SOLVED] Function whit intervals
    By arn0ldas in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2014, 08:55 AM
  4. Calculating quantiies from irregular intervals to regular intervals
    By abhi1421 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-15-2014, 06:34 AM
  5. [SOLVED] date intervals
    By jer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-13-2006, 12:25 PM
  6. Date Intervals
    By abohnsac in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-10-2005, 09:13 PM

Tags for this Thread

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