Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Require formula for +1,-1 point acceptable in excel

0

Hi, 

I am looking for formula where +1,-1 point acceptable in excel.

I mean any formula for Plus/Minus 1 point acceptance. 

Please guide me for the same.

Attached sheet for your reference.

Regards,

Nitil

Revision 1

Hi,
I wanted formula for 1 point plus or minus is acceptable.
Means the difference between one cell and another cell should not be more than 1 points. Please guide how to capture the same in formula.
For example,
Cell 1 = 25 and Cell 2 = 25, Acceptable
Cell 1 = 24 and Cell 2 = 25, Acceptable
Cell 1 = 25 and Cell 2 = 26, Acceptable.
Cell 1 = 25 and Cell 2 = 27, = Not Acceptable as Range difference between two cell is more than 1 point. 
Cell 1 = 27 and Cell 2 = 25, = Not Acceptable as Range difference between two cell is more than 1 point. 
Thanks,
Nitil

Answer
Discuss

Answers

0
Selected Answer

Hi Nitil

You don't say what the criteria for +1 and -1 are but the IF function can be used here.

That takes the form =IF(<<test>>, <<value if test is logical TRUE>>, <<value if test is FALSE>>)

Your spreadsheet has a single value for "Range of Age" so I've assumed that is a maximum age and in E3 (for example), the formula is:

=IF(D3<=E3,1,-1)

Here, the test equates to "Is D3 less than or equal to E3?". If that's true, the cell shows the 1 but if not, it will display -1 (see cells below that).

If the "Range of Age"  is a minimum, change the test to "D3>=E3".

IF can output  text too- in the green cells G3 to G5 of my revised workbook (attached), I've changed the "less than" formula from E3 to show "Acceptable" or "Does not meet critieria" using this variant:

=IF(D3<=E3,"Acceptable","Does not meet criteria")

If however you really have a range age, IF can do that if you combine it with the AND function. The IF test is then AND(<<test 1>>, <<test 2>>) and will be TRUE only if both tests are met. In the orange cells G8 to G10 of my revised workbook (attached), I've tested against a minmium and maximum age (in E8 and F8 for example) and use this formula (where the test is in bold:

=IF(AND(D8>=E8, D8<=F8),"Acceptable","Reject")

and you could change the text for 1 and -1 if the value feeds into a scoring system.

In fact, if the two ages are always the same, you don't need to repeat them but could put them in E1 and F1 for example and make the test

AND(D8>=$E$1, D8<=$F$1)
where the $ sign fixes the cell references when you copy the formula down or elsewhere.

Hope this helps. Check out the Tutuorial section for help on IF and AND if you need to.

REVISION 1: Spreadsheet revised to show a formula where Acceptable means the age is no more than 1 year from a reference age (as per user clarification to the Question). This is shown in yellow cells E14 to E18 of the revised workbook attached and uses the ABS function since ABS(number) returns the value of a number without the + or - sign (and is applied to the subtraction of one cell value from another). This is used as the test for the IF (highlighted in bold below):

=IF(ABS(D14-E14)<=1,"Acceptable","Not acceptable")
Discuss

Discussion

Hi,
I wanted formula for 1 point plus or minus is acceptable.
Means the difference between one cell and another cell should not be more than 1 points. Please guide how to capture the same in formula.
For example,
Cell 1 = 25 and Cell 2 = 25, Acceptable
Cell 1 = 24 and Cell 2 = 25, Acceptable
Cell 1 = 25 and Cell 2 = 26, Acceptable.
Cell 1 = 25 and Cell 2 = 27, = Not Acceptable as Range difference between two cell is more than 1 point. 
Cell 1 = 27 and Cell 2 = 25, = Not Acceptable as Range difference between two cell is more than 1 point. 
Thanks,
Nitil
NitilA (rep: 14) Feb 25, '21 at 6:32 am
Nitil

See Revision 1 to my Answer but next time please try to make your question clear to begin with. If any big clarifications are needed ;later, please put them in the original Question niot the Discussion (so others understand if your question relates to their problem too).
John_Ru (rep: 6142) Feb 25, '21 at 6:52 am
Nitil

Thanks for selecting my answer and for revising your question. I'll now edit my Answer to remove the reference to the discussion.
John_Ru (rep: 6142) Feb 25, '21 at 8:04 am
Nitil
I've provided an Excel solution to your request but if you are using the formula for business reasons, you should check to ensure the use does not breach either your company's and your country's age discrimination rules. 
John_Ru (rep: 6142) Feb 25, '21 at 8:45 am
Add to Discussion
0

Hi Nitil,

I see you have selected John_Ru'sanswer, but I would like to offer another option.

The following formula compares the age in "D" to the range in "E". If the age is within +/-1 of the range then "acceptable" will be put in the cell, if greater than +/-1 then "not acceptable" will be put in the cell.

=IF(OR(D3-E3<=-1,D3-E3<=1),"acceptable","not acceptable")

Enjoy

WillieD24

Discuss

Discussion

Willie

Please check your formula- I think it works well except for the 4th case cited by Nitil:
Cell 1 = 25 and Cell 2 = 27, = Not Acceptable as Range difference between two cell is more than 1 point.

Your formula produces acceptable in that case (since you have Cell 1- Cell 2 <=-1 as a criteria for "acceptable" and the sum produces -2 which is less than -1).
John_Ru (rep: 6142) Mar 7, '21 at 9:53 am
John_Ru,

Good catch. I was a bit too hasty and upon review, your solution using the ABS function is the best one. Thanks for pointing out my error.

WillieD24
WillieD24 (rep: 557) Mar 8, '21 at 9:17 pm
Willie 
Thanks for posting your solution anyway. I've also made mistakes in rushing but that can lead to learning moments. I generally look at the solutions posted since the experience of others shows  approaches I'd not thought of (and we know there are always several ways to do anything in Excel, thankfully). 
John_Ru (rep: 6142) Mar 9, '21 at 3:18 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login