# Combining two conditional statements into one formula

• Hello,

I need help with the following statement:

I want to do a graphic schedule in Excel, so I was using the current formula:

=IF(AND(I2>=\$C3,J2<=\$D3),1," ")

Where I2 is the start time and J2 is the end time and C3 and D3 are 15 min intervals, but the problem that I'm facing is when I want to also put the break time using this formula:

=IF(AND(I2>=\$E3,J2<=\$F3),2," ")

Where E3 and F3 are the start and end time of the break in question

How could I combine both?

• Re: Combining two conditional statements into one formula

Decide which of the two options take precedent then nest the if statements.

So for example if the output of 1 is the more important then:

=IF(AND(I2>=\$C3,J2<=\$D3),1, IF(AND(I2>=\$E3,J2<=\$F3),2,""))

So if the first clause is satisfied, you get a 1.
If the second clause is satisfied, you get a 2.
If neither clause is satisfied, you get a blank (or a space as you had it but not sure if you had a good reason for that, I've removed the space in the example).

• Re: Combining two conditional statements into one formula

That helped a lot. Before that I was placing the first paragraph in the beginning, but I changed the order and it gave me what I wanted. Thanks for your help

• Re: Combining two conditional statements into one formula