+ Reply to Thread
Results 1 to 6 of 6

using IF function to use different formulas depending on different rules

  1. #1
    Registered User
    Join Date
    11-04-2013
    Location
    Chesham
    MS-Off Ver
    Excel 2010
    Posts
    33

    using IF function to use different formulas depending on different rules

    Hi,

    I have got to this stage with a formula but cannot understand why it isn't working:

    =IF(OR(A2=1,A2=2),(MIN(B2:B6)+50),(MAX(B2:B6)+50))

    If A2 equals 1, I want it to add 50 on to the smallest (earliest) date in C2:C5.

    BUT

    If A2 equals 2, I want it to add 50 on to the largest (latest) date

    The formula just adds 50 on the smallest (earliest) date, whether A2 equals 1 or 2.

    What am I doing wrong?

    Any help or advice would be much appreciated.

    Toby
    Last edited by Tnashnhsp1; 11-27-2013 at 11:35 AM.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Using the IF Function

    Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This formula returns "" if A2 is neither 1 nor 2. Change the last "" in the formula if you want this value to be something else.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Using the IF Function

    your formula says if a is 2 or a is 1, use the minimum date.

    OR(A1=1,A2=2) equals true if either condition is met, presumably you want:
    =IF(A2=1,(MIN(B2:B6)+50),IF(A2=2,(MAX(B2:B6)+50),""))

  4. #4
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,885

    Re: Using the IF Function

    Your OR statement evaluates to TRUE if A2 is either 1 or 2. Hence it will always be true, hence it will always be MIN + 50

    Try:
    =IF(A2=1,MIN(B2:B6)+50,IF(A2=2,MAX(B2:B6)+50))
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  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
    53,049

    Re: Using the IF Function

    Hopefully 1 of the suggestions above worked for you

    However, Administrative Note:
    • We would love to help you with your query, but first, before we can proceed…
    • Please see Forum Rule #1 about proper thread title
    • Please PM me when complete (Also, include a link to your thread - copy from the adress bar) and this post will be removed which will reset the replies to zero…

      To change a Title on your post, click EDIT on you're 1st post, then Go Advanced and change your title
    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

  6. #6
    Registered User
    Join Date
    11-04-2013
    Location
    Chesham
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: using IF function to use different formulas depending on different rules

    many thanks for your help, these formulas worked, especially thanks for explaining why I was wrong, I have much to learn yet

+ 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 Function referencing IsNumber, Match, Left function on separate sheets
    By Touch9713 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-12-2013, 10:09 PM
  2. [SOLVED] Using Offset function as the array in the PercentRank function is giving wrong result
    By Bobneil in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-06-2013, 09:29 PM
  3. Replies: 1
    Last Post: 03-21-2012, 11:22 AM
  4. Replies: 2
    Last Post: 03-20-2009, 01:29 PM
  5. Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 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