+ Reply to Thread
Results 1 to 7 of 7

An IF formula with a variable?

  1. #1
    Registered User
    Join Date
    02-28-2020
    Location
    The Netherlands
    MS-Off Ver
    ? 2016-2019
    Posts
    6

    An IF formula with a variable?

    Hi all,

    I want to place a formula in cel C1 that containes the following:
    If the value in A1 is lower than the value in B1-0,5 then return “High” (meaning the value in cel B1 is high)
    If the value in A1 varies between the value in B1-0,5 and the value in B1+0,5 then return “OK” (meaning the value in cel B1 is OK)
    If the value in A1 is higher than the value in B1+0,4 then “Low” (meaning the value in cel B1 is low)

    The value in B1 can ofcourse vary.
    So, if the value in B1 is 2, and the value in A1 is
    -from 1,5 til 2,4, then C1 should return OK
    -below 1,5, then C1 should return Low
    -above 2,4, then C1 should return High

    I came up with this
    PHP Code: 
    =IF(AND(A1<B1-0,5;”High”;IF(A1>B1+0,5;”Low”;IF(A1<=B1-0,5;A1>=B1+0,4;OK”))) 
    ….. but it doesn’t work… What should the formula be?

    Thanks in advance for looking into this.
    Greetings,
    P
    (I don't even know what the description of this topic / of this type of formula should be)

  2. #2
    Registered User
    Join Date
    02-28-2020
    Location
    The Netherlands
    MS-Off Ver
    ? 2016-2019
    Posts
    6

    Re: An IF formula with a variable?

    Sorry, there should be a ")" extra on the end I think. But it still doesn't work...

  3. #3
    Registered User
    Join Date
    02-28-2020
    Location
    The Netherlands
    MS-Off Ver
    ? 2016-2019
    Posts
    6

    Re: An IF formula with a variable?

    Again sorry, I also forgot an " before OK.

    This is the formula again
    PHP Code: 
    =ALS(EN(A1<B1-0,5;"H";ALS(A1>B1+0,5;"L";ALS(A1<=B1-0,5;A1>=B1+0,4;"OK")))) 
    And I get "#NAME?" in return.

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: An IF formula with a variable?

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: An IF formula with a variable?

    =IF(A1<B1-0,5;”High”;IF(A1<B1+0,5;”OK”;"Low"))

  6. #6
    Registered User
    Join Date
    02-28-2020
    Location
    The Netherlands
    MS-Off Ver
    ? 2016-2019
    Posts
    6

    Re: An IF formula with a variable?

    Thank you, that's it!!

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

    Re: An IF formula with a variable?

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    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.

+ 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. How can i add a 'but-if' then.....variable to a formula?
    By Taupo58 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-21-2015, 03:57 AM
  2. Changing column variable on a copied formula instead of row variable
    By dsw283 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-06-2014, 04:13 PM
  3. Replies: 4
    Last Post: 07-12-2013, 12:14 PM
  4. [SOLVED] VBA Variable in Sum formula
    By DHuskic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2013, 01:55 PM
  5. Using a variable in a formula with VBA
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2010, 12:38 PM
  6. How to Use a Variable in a Formula
    By thundermocos in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2007, 01:56 PM
  7. Replies: 1
    Last Post: 10-31-2006, 08:34 AM

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