Conditional Formatting/Formula

Arts

Well-known Member
Joined
Sep 28, 2007
Messages
765
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all

I have two dates, Due Date and Actual Dates of which I am doing a calculation of to get the number of days between the actual date and due date. What I was hoping to do was use conditional formatting to colour the cell different colours depending on how late or early the date difference was. Now the issue I seem to have is that I am trying to highlight anything that is over a certain time by extracting just the number from the Date Difference Column.
so anything > refers to Days Late, < Days Early

Red: >28 <-28 days (so anything more than -28 days Early as Red)
Amber: >14 but less than 28, <-28 (so anything upto -28 days Early as Amber)
Green: <14 <-14 (so anything upto -14 days Early as Green)


Due DateActual End DateDate Difference
30/08/23​
02/09/23​
3 Days late
14/07/22​
21/04/22​
-84 Days Early
14/04/23​
20/03/23​
-25 Days Early
14/04/23​
20/03/23​
-25 Days Early

Within the conditional formatting, I have done (shown below) this seems to highlight the 3 days late as Red but should be Green. I maybe completely on the wrong path and there could be an easier way to extract the number from the text within conditional formatting, as always any help is appreciated.

1693494428935.png
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
try multiplying by 1 to take it from text to number.
=LEFT(M11,SEARCH" ",M11-1)*1>28
 
Upvote 0
Solution
That has done it!! Thank you so much!

Can I ask what is the text part? That it's giving me true or the date is seen as text? It was only yesterday where I I had a date question and Joe mentioned that dates are numbers where I needed to add 14 days to a date so am unsure where the Text aspect is


edit if I use the formula =LEFT(M11,SEARCH" ",M11-1) this gives me a number
 
Upvote 0
That has done it!! Thank you so much!

Can I ask what is the text part? That it's giving me true or the date is seen as text? It was only yesterday where I I had a date question and Joe mentioned that dates are numbers where I needed to add 14 days to a date so am unsure where the Text aspect is


edit if I use the formula =LEFT(M11,SEARCH" ",M11-1) this gives me a number
It looks like a number, but does it show up on the left side of the column? Means its recognized as text. Left, right, and mid are text functions.
 
Upvote 0
That has done it!! Thank you so much!

Can I ask what is the text part? That it's giving me true or the date is seen as text? It was only yesterday where I I had a date question and Joe mentioned that dates are numbers where I needed to add 14 days to a date so am unsure where the Text aspect is


edit if I use the formula =LEFT(M11,SEARCH" ",M11-1) this gives me a number
The result of the LEFT function by default is a string (Text). Multiplying by 1 converts the text to a number.
 
Upvote 0
It looks like a number, but does it show up on the left side of the column? Means its recognized as text. Left, right, and mid are text functions.
I'll check tomorrow out of all things we had a fire alarm in the office and subsequently left for the day. I'll confirm tomorrow about it being on the left though suspect you are right.
 
Upvote 0
It looks like a number, but does it show up on the left side of the column? Means its recognized as text. Left, right, and mid are text functions.

It does indeed show up on the left, good call.

How would I then alter the formula to include a range I seem to struggling to get there so if I wanted it highlight red if it was over 28 days late and then highlight red if it was more than -28 days early

Edit: Or would it be a list of single formula entries within the conditional formatting
 
Last edited:
Upvote 0
It does indeed show up on the left, good call.

How would I then alter the formula to include a range I seem to struggling to get there so if I wanted it highlight red if it was over 28 days late and then highlight red if it was more than -28 days early

Edit: Or would it be a list of single formula entries within the conditional formatting
If you use the ABS function (absolute value), it will convert all negative numbers to positive, so you could do something like:
Excel Formula:
=ABS(LEFT(M11,SEARCH" ",M11-1)*1)>28
 
Upvote 0
If you use the ABS function (absolute value), it will convert all negative numbers to positive, so you could do something like:
Excel Formula:
=ABS(LEFT(M11,SEARCH" ",M11-1)*1)>28

Ah Joe (Afternoon) I was literally tussling with this as you replied as the issue I was having was if it the result was less than 14 days I was hoping this would go green but then I had -111 days which should be red is turning Green not to mention having to incorporate the ambers... I shall give your reply a whirl

1693566620765.png
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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