# Thread: if logical formula Thanks: 0 Likes: 0

1. ## if logical formula

Hi excel gurus
I need a formula that will return a value of 1 in a cell, if the contents of another cell are between 2 ranges, ie, it needs to return a value of 1 if the test cell contains any number between 60 and 64 or 86 and 90. if the value in the test cell is not within these 2 ranges, it needs to return a value of 0... I have tried using if(and but can only get it to work for 1 range of values, not 2. perhaps there is an easier way? this is for setting up colour formatting in KPIs.. so once I get this sorted, the rest should be a breeze.. thanks in advance
DH

2. ## Re: if logical formula

Does this work?

=IF(OR(AND(F2>=60,F2<=64),AND(F2>=86,F2<=90)),1,0)

 Result Number 0 55 0 66 0 77 1 88 0 99 1 60 1 64 1 86 1 90

3. ## Re: if logical formula

Another option
=--OR(AND(A2>=60,A2<=64),AND(A2>=86,A2<=90))

4. ## Re: if logical formula

thanks. so grateful

5. ## Re: if logical formula

Glad we could help & thanks for the feedback