+ Reply to Thread
Results 1 to 7 of 7

Please help explain this If Statement help

  1. #1
    Registered User
    Join Date
    01-02-2014
    Location
    Cal
    MS-Off Ver
    Excel 2007
    Posts
    3

    Please help explain this If Statement help

    Can you someone dicifer this formula, for the life of me I cannot get it...although the final answer is 10 and Q3= 1/16/2014. If you could break it out by numbers or something that would be awesome!

    =IF(-IF(Q3<DATE(2014,1,3),50,0)+IF(Q3<DATE(2014,1,6),20,0)+IF(Q3<DATE(2014,1,7),10,0)<0,15,-IF(Q3<DATE(2014,1,3),50,0)+IF(Q3<DATE(2014,1,6),20,0)+IF(Q3<DATE(2014,1,7),10,0))

    Thanks
    Jon
    Last edited by FDibbins; 01-02-2014 at 09:25 PM.

  2. #2
    Registered User
    Join Date
    01-02-2014
    Location
    Cal
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: If Statement help

    correction Q3 = 1/6/2014

  3. #3
    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
    52,936

    Re: Please help explain this If Statement help

    Hi and welcome to the forum If you break that down, it becomes a bit easier to understand...
    =IF(
    -IF(Q3<DATE(2014,1,3),50,0)
    +IF(Q3<DATE(2014,1,6),20,0)
    +IF(Q3<DATE(2014,1,7),10,0)
    <0,15,
    -IF(Q3<DATE(2014,1,3),50,0)
    +IF(Q3<DATE(2014,1,6),20,0)
    +IF(Q3<DATE(2014,1,7),10,0))

    Not sure if the bolded part should be negative or not?

    essentially what it is doing is adding a series of values, based on how Q3 compares to specified dates (DATE(2014,1,3) etc). It then gived 15 if the sum is < 0, otherwise it adds them up
    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

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Please help explain this If Statement help

    welcome to the forum, Jon. let me break up the formula into 4 parts so that you'll see ii & iv are the same.
    =IF(
    -IF(Q3<DATE(2014,1,3),50,0)+IF(Q3<DATE(2014,1,6),20,0)+IF(Q3<DATE(2014,1,7),10,0)
    <0,15,
    -IF(Q3<DATE(2014,1,3),50,0)+IF(Q3<DATE(2014,1,6),20,0)+IF(Q3<DATE(2014,1,7),10,0))

    so it's saying IF part ii is less than 0, show as 15. otherwise, calculate the part ii (which is the same as iv). so the complex section is probably part ii of it. it's saying IF Q3 is:
    1. less than 3 Jan 2014, show as -50 plus
    2. less than 6 Jan 2014, show as 20 plus
    3. less than 7 Jan 2014, show as 10

    if it's 7 Jan, it will show as 0 as it doesn't qualify under any of it. 6 Jan will be lesser than 7 jan, so show as 10. 5 jan is lesser than both 2 & 3, so show 10 + 20. 2 Jan is less than all 3 of them, so it adds them up & becomes -20. since you have part iii saying if it's less than 0, show 15, it returns 15.
    what i cannot understand is the need for for less than 3 Jan 2014 since it's a definite negative. so why not just:
    =IF(Q3<DATE(2014,1,3),15,IF(Q3<DATE(2014,1,6),20,0)+IF(Q3<DATE(2014,1,7),10,0))

    Edit: ahh Ford beat me to it. but i wrote so much i decided to just post it. =)

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  5. #5
    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
    52,936

    Re: Please help explain this If Statement help

    Edit: ahh Ford beat me to it. but i wrote so much i decided to just post it. =)
    @ Ben, I know that feeling really well - spend a while creating a formula, post it and find someone beat you to it lol

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Please help explain this If Statement help

    @Ford:
    more of typing the explanation really.
    i usually refresh the page if it's just a formula. and when it's the same, i definitely won't post it. i didn't bother to even refresh for this one, since i already typed so much!

  7. #7
    Registered User
    Join Date
    01-02-2014
    Location
    Cal
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Please help explain this If Statement help

    Your help is greatly appreciated.


    ok ive replaced the formula with Bens...so it matches all of the previous except these..
    same criteria but S595=1/6/1014 and the old formula showed 50, yet yours shows 25.


    =IF(-IF(S595<DATE(2014,1,3),100,0)+IF(S595<DATE(2014,1,6),25,0)+IF(S595<DATE(2014,1,7),50,0)<0,15,-IF(S595<DATE(2014,1,3),100,0)+IF(S595<DATE(2014,1,6),25,0)+IF(S595<DATE(2014,1,7),50,0))

+ 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] If statement that will look among multiple criteria and generate a statement
    By liz5818 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-01-2013, 04:12 PM
  2. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  3. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  4. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  5. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 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