Using if statement, for a number between two values.

mon_751

New Member
Joined
Feb 19, 2016
Messages
4
I crated random numbers between 0 and 100, and I want to convert those numbers to have a specific value from 1-6 depending on the random number value. Those specific values are the following:
0-30 should output a 1
30-40 should output a 2
40-60 should output a 3
60-70 should output a 4
70-75 should output a 5
75-100 should output a 6.
I taught about using the IF statement like this.. (If(A1=0,1,IF(A1=1,1,IF(A1=2,1...) but it will be a very long function.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
One way:
Code:
=IF(A1>75,6,IF(A1>70,5,IF(A1>60,4,IF(A1>40,3,IF(A1>30,2,1)))))
 
Upvote 0
Try

=MATCH(A1,{0,31,41,61,71,76})


Though your ranges overlap each other, ie should 30 be 1 or 2 ??
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top