If Formula to Select Answer from List

JenMcG

New Member
Joined
Dec 2, 2016
Messages
46
Hello,

I help to generate a formula that will select an answer from a list (1-5) from the following range:

5= 0 to 4 hours
4= 4.01 to 12 hours
3= 12.01 to 24 hours
2= 24.01 to 28 hours
1= 28.01+ hours

I already have the calculation formula to generate the total number of hours. Now I need a formula to select a score (1-5) based on the above criteria.

The cell that has the answer for the calculation of time is AG6.

Thanks,
Jen
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
If the value in AG6 actually a "date/time" value, or just a simple number with decimal?
An easy way to verify is to change the Format to General, and see if the number changes or not.

If numbers, you can just use this formula:
Code:
=LOOKUP(AG6,{0,4.01,12.01,24.01,28.01},{5,4,3,2,1})
 
Last edited:
Upvote 0

Excel 2010
ABCDEFG
1num of hrsScore05
22824.014
312.013
424.012
528.011
Sheet5
Cell Formulas
RangeFormula
B2=VLOOKUP(A2,F1:G5,2)
 
Upvote 0
If it entered as time, then you will need to divide each of the values in the second argument of the formula ({0,4.01,12.01,24.01,28.01}) by 24 to get them to work correctly.
That is because dates/times are actually stored as numbers in Excel, specifically the number of days since 1/0/1900, and hours are just the fraction of one day.
So 12 hours is equivalent to 0.5 in Excel.
 
Upvote 0
Hello,

I tried the above and it didn't seem to work. It returned an NA.


Received Date

Contacted Date

TAT DAYS FROM RECEIVED TO CONTACTED

SCORE

5/2/2021 6:31:47 PM

5/3/2021 12:42:29 PM

18:10:42

3/22/2021 3:28:28 PM

3/22/2021 3:37:01 PM

0:08:33

5/3/2021 8:13:52 AM

5/3/2021 12:44:48 PM

4:30:56


<tbody>

</tbody>
Received Date Contacted Date TAT DAYS FROM RECEIVED TO CONTACTED SCORE
5/2/2021 6:31:47 PM 5/3/2021 12:42:29 PM 18:10:42
3/22/2021 3:28:28 PM 3/22/2021 3:37:01 PM 0:08:33
5/3/2021 8:13:52 AM 5/3/2021 12:44:48 PM 4:30:56
 
Upvote 0
If you make the change I suggested in my last post, it works (it returns 3, 5, 4 respectively, based on your examples).
Here is the formula with the adjustments I mentioned:
Code:
=LOOKUP(AG6,{0,0.167,0.501,1.01,1.167},{5,4,3,2,1})
 
Upvote 0
Excel 2010
ABCDEFG
1num of hrsScore0:00:005
218:10:4234:00:364
312:00:363
424:00:362
528:00:361

<colgroup><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
B2=VLOOKUP(A2,F1:G5,2)
F1=0/24
F2=4.01/24
F3=12.01/24
F4=24.01/24
F5=28.01/24

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
I'm so sorry- you have both been very helpful but I can't get either of these to work. Doesn't it matter that my workbook is set to 1904 time/date?

Could this be done in a formula? I tried to write one but it wouldn't work. But I've used one like this in the past for something similar:

=IF(AND(AG6>=28:01:00),1,IF(AND(AG6<=28:00:00,AG6>=24:01:00),2,IF(AND(AG6<=24:00:00,AG6>=12:01:00),3,IF(AND(AG6<=12:01:00,AG6>=24:00:00),4,5))))



 
Upvote 0

Forum statistics

Threads
1,215,450
Messages
6,124,912
Members
449,195
Latest member
Stevenciu

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