smirnoff103
smirnoff103

Reputation: 328

Problem with result of a IF - AND function

I need to substract the last number of a 3 digit number (in fact a two decimal of comma number). I do this with the function:

=RIGHT(A1;1)

The result I got is correct.

After I need to "round" this number. If the number is between 2 & 6 it should be 4, otherwise it should be 9. I use this function for this:

=IF(AND((A2<7);(A2>1));4;9)

Strangely, the function is not working on the "RIGHT" function here first mentioned, but if I enter the value 'hardcoded' in a cell, and use the same function from here above it's working like a charm. I was first thinking it had to do with the cell where the result was: text, number,... But even after changing it into text it's still not working correctly.

printscreen

Any idea what the problem could be ? Thanks for your time.

Upvotes: 1

Views: 34

Answers (2)

Error 1004
Error 1004

Reputation: 8220

Try:

=IF(AND((RIGHT(A1;1)*1)>1;(RIGHT(A1;1)*1)<7);4;9)

Upvotes: 0

rmbradburn
rmbradburn

Reputation: 308

When you use =RIGHT(A1;1), I think it's returning a text result. Try =VALUE(RIGHT(A1;1)). It worked for me.

Upvotes: 1

Related Questions