:confused: Nested if then else statement

P

polk383

Hello All!
I never tried to do anything like this before so here goes! I am
trying to create a nested if then else statement. What I have is 7
fields one of which I created the other 6 where exported data. In the
6th field I have times in there that is subtracting a from fields B and
C. In field H There are times in the format [h]:mm:ss. I need to have
a statement showing that if the time is below 1:00:00 then in the cell
will be "less than 1 hour" if it is between 2 - 4 hours it will say
"between 2 - 4 hours" and if it is over 4 hours then it will show "Over
4 hours" Here is what I have created so far and I am unable to get this
thing to function correctly.


Code:
--------------------
=IF(H2<1:00:00,"Less than 1 hour",IF(H2>2:00:00,"Over 2 hours",IF(H2>4:00:00,"Over four hours")))
--------------------


I am at a loss to get this thing to see between 2 - 4 hours and just to
get it to function correctly!

Thanks everyone!!
 
D

daddylonglegs

What if the time is between 1 and 2 hours? Perhaps something like this

=IF(H2<"1:00:00"+0,"Less than 1 hour",IF(H2>"4:00"+0,"Over 4
hours",IF(H2>"2:00"+0,"Over two hours","between 1 and two hours")))
 
P

pdberger

Polk --

The problem lies in the 2nd part of your 'if' statement. It doesn't address
what happens between 1 & 2 hours and, if it's ANY time over two hours, then
you only get one answer. You want to keep your 'greater than' or 'less than'
consistent. So you might try:

=IF(H2<1:00:00,"Less than 1 hour",IF(H2<2:00:00,"1 to 2
hours",IF(H2<4:00:00,"2 to 4 hours")))

etc.

HTH
 
A

Ardus Petus

=IF(H2>TIMEVALUE("4:00:00"),"Over four
hours",IF(H2>TIMEVALUE("2:00:00"),"Over 2
hours",IF(H2>TIMEVALUE("1:00:00"),"1-2 hours","Less than 1 hour")))

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top