Reputation: 1
How do I check if a number is in a range of numbers (not a range of cells). For example in many programming languages I can write a >= 1 && a <= 7. How do I express this in Google Sheets?
I tried to apply this solution, but how would that formula work in order to handle multiple ranges? For example:
C12 = 5
I want to check if C12 is either in ranges:
I'm trying the following but it's not working:
=IFS(AND(C12>=1,C12<=10),"1-10",(AND(C12>=11,C12<=25),"11-25","26-50"))
Upvotes: 0
Views: 2526
Reputation: 152450
IFS need pairs and it will short circuit at the first TRUE so we can shorten it to:
=IFS(C12<=10,"1-10",C12<=25,"11-25",TRUE,"26-50")
Or we can use CHOOSE:
=CHOOSE(MATCH(C12,{1,11,26}),"1-10","11-25","26-50")
Upvotes: 2
Reputation: 96753
How about:
=IF(AND(C12>=1,C12<=10),"1-10",IF(AND(C12>=11,C12<=25),"11-25",IF(AND(C12>=26,C12<=50),"26-50","NONE")))
same in Google-Sheets:
Upvotes: 1