# IF functions/conditional formatting

#### PP299

##### New Member
Hi All

I thought I had this sussed but as soon as my If function was entered into a particular cell my conditional formatting went ever so slighlty haywire.

This is my problem I have an if function in cell K8 (expected end date) which is =IF(c2=2, J8+140,J8+168) but I need to add some conditional formatting which states that cell K8 will turn red when it reaches 40 days before the current end date, amber when it hits 100 days and green any other time.

I have examples from a previous posting but they don't work with the IF function in place!

I hope you can help me.

### Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

#### Andrew Poulsom

##### MrExcel MVP
What is "the current end date"? The value in a cell?

#### PP299

##### New Member
yes the current end date is a value in the cell for instance if someone started on 01/04/09 I add that plus 140 days for level 3 and 168 for level 3 it then calculates the expected end date

#### Andrew Poulsom

##### MrExcel MVP
So which cell contains the current end date that is relevant to K8 for use in conditional formatting?

#### PP299

##### New Member
the current end date is in cell K8 as well, i want that end date to be conditionally formatted

#### Andrew Poulsom

##### MrExcel MVP
What cell would you be comparing K8 with to conditionally format it? Or do you want to compare it with today's date, eg:

=K8>=(TODAY()+100)

#### lenze

##### Legend
It would probably been better to continue in your original thread or to link to it so others could see what's been tried, http://www.mrexcel.com/forum/showthread.php?t=380559

What is happening that the CF given before does not work? I think this does
Cond1
Code:
``=(TODAY()>K8)*(J8)``
Cond2
Code:
``=(J8)*(K8-TODAY()<40)``
Cond3
Code:
``=J8``

lenze

#### PP299

##### New Member
the problem with the ones before is that they are going amber!! but yes it is to do with todays date - I am trying to format the column so that when it reaches 40 days / 100 days before expected end date it goes to the relevant colour

#### Andrew Poulsom

##### MrExcel MVP
You need to get the conditions in the right order. The condition for greater than 100 must come before greater than 40. Excel applies the format of the first condition that evaluates to TRUE.

#### lenze

##### Legend
I'm still confused from your original post. Do you want?
Code:
``````1. Today() > K8  'Format Red
2. Today() > K8-40 'Format Amber
3. Today() > K8-100 'Format Green``````
lenze

Replies
3
Views
370
Replies
1
Views
121
Replies
1
Views
534
Replies
10
Views
657
Replies
1
Views
168

1,191,608
Messages
5,987,642
Members
440,104
Latest member
thigarette

### 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.

### Which adblocker are you using?

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

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