+ Reply to Thread
Results 1 to 4 of 4

Include inequality inside cell for IF formula condition

  1. #1
    Registered User
    Join Date
    09-23-2014
    Location
    Washington, DC
    MS-Off Ver
    2011
    Posts
    92

    Include inequality inside cell for IF formula condition

    Hi All,

    Not something I've ever come across. I'm trying to write an IF statement that considers a benchmark value input by the user. So, let's say we're looking at the price and quantity of widgets. A user could enter "20" in cell F5 and the formula might return the number of widgets with a price over 20. That's simple enough. But what if I wanted to let the user include the inequality in cell F5. Rather than typing "20" like in the previous example, the user in this instance would type ">20" or "<20" to get the count of widgets costing either more than or less than 20. Has anyone seen anything like this before?

    If the inequality is in the cell (ex. ">=20"), excel reads that as text and doesn't evaluate the expression. So I tried parsing the inequality and the value seperately (ex. "<10" is entered in cell F5; IF(5&LEFT(F5,1)&RIGHT(F5,2),1,0)) but this also returns an error.

    Hoping someone has other ideas!

    Best,

    Alex

  2. #2
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Include inequality inside cell for IF formula condition

    Something like this could work. I don't know what your formula is so I used COUNTIF
    Values are in A3:A9. The formula is in C1 and the condition required is in A1.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    A
    B
    C
    1
    <=4
    4
    2
    3
    1
    4
    2
    5
    3
    6
    4
    7
    5
    8
    6
    9
    7
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  3. #3
    Registered User
    Join Date
    09-23-2014
    Location
    Washington, DC
    MS-Off Ver
    2011
    Posts
    92

    Re: Include inequality inside cell for IF formula condition

    Thanks for your reply, newdoverman. That's not quite what I'm looking for. Using the grid you provided, I'm looking to put an if statement in B3 that checks the value in A3 and evaluates to TRUE/FALSE depending on the condition in A1. Does this make sense?

  4. #4
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Include inequality inside cell for IF formula condition

    Maybe like this?? Enter in B3 and fill down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This can be shortened to:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    A
    B
    1
    <5
    2
    3
    1
    TRUE
    4
    9
    FALSE
    5
    3
    TRUE
    6
    4
    TRUE
    7
    5
    FALSE
    8
    6
    FALSE
    9
    7
    FALSE
    Last edited by newdoverman; 10-21-2016 at 03:27 PM.

+ 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 condition inside a for loop
    By Ronanus43 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-19-2015, 01:41 PM
  2. [SOLVED] Include another match condition to formula
    By MATU70 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-17-2014, 01:07 AM
  3. Need to modify formula to include extra condition
    By LeithKaouas in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-18-2014, 08:35 AM
  4. Inequality in named formula causing problems
    By whc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-08-2013, 06:21 PM
  5. if condition inside msgbox
    By kash in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2012, 08:24 AM
  6. Include Excel Application Inside Winforms
    By Tinjano in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2005, 03:05 AM
  7. Amend formula to include addition condition
    By Pat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-16-2005, 12:06 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