Conditional Formatting two dates:

FGaxha

Board Regular
Joined
Jan 10, 2023
Messages
221
Office Version
  1. 365
Platform
  1. Windows
Hi Master,
I need help to calculate with conditional formatting between two dates:
If B2:B8-G2 =<12month highlight cells in red and column C red flag including number of month, not number on C

1682087478148.png
 

Attachments

  • 1682087213830.png
    1682087213830.png
    34.6 KB · Views: 4

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
write a conditional rule

=AND(B2<>"",B2<DATE(YEAR(TODAY())+1,MONTH(TODAY()),DAY(TODAY())))

will highlight red for any date within a year in the future

i have used today() within the formula rather than reference another cell - but can do if you want

dont understand the column c comments


Book8
AB
1
21/1/23
31/1/24
41/1/25
51/1/26
61/1/23
71/1/24
81/1/25
91/1/26
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B9Expression=AND(B2<>"",B2<DATE(YEAR(TODAY())+1,MONTH(TODAY()),DAY(TODAY())))textNO


for 2007, 2010 , 2013 , 2016 , 2019 or 365 Subscription excel version
Conditional Formatting

Highlight applicable range >>
B2:b100 - Change, reduce or extend the rows to meet your data range of rows

Home Tab >> Styles >> Conditional Formatting
New Rule >> Use a formula to determine which cells to format
Edit the Rule Description: Format values where this formula is true:
=AND(B2<>"",B2<DATE(YEAR(TODAY())+1,MONTH(TODAY()),DAY(TODAY())))

Format [Number, Font, Border, Fill]
choose the format you would like to apply when the condition is true
OK >> OK

Note: Images are difficult to see , and also requires that I input all the data myself, which means I may make an error, which is very time consuming, and from my point of view less likely to get a response, if a complicated spreadsheet. Plus we cannot see any of the formulas used.

Therefore -

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
Thank you for the formula, i have not tried yet. Column C is current date G2 - B2.
Based on the result i have add flag colors
 
Upvote 0
I would like to highlight in red Column A and B and C?
 
Upvote 0
ok, slight change to highlight column A as well

for 2007, 2010 , 2013 , 2016 , 2019 or 365 Subscription excel version
Conditional Formatting

Highlight applicable range >>
A2:B100 - Change, reduce or extend the rows to meet your data range of rows

Home Tab >> Styles >> Conditional Formatting
New Rule >> Use a formula to determine which cells to format
Edit the Rule Description: Format values where this formula is true:
=AND($B2<>"",$B2<DATE(YEAR(TODAY())+1,MONTH(TODAY()),DAY(TODAY())))

Format [Number, Font, Border, Fill]
choose the format you would like to apply when the condition is true
OK >> OK

Column C is current date G2 - B2.
which is the days , BUT you want Months ..... what about fractions of months

1/1/24 - 1/1/23 is 365 days 12 months
But what about
1/1/24 - 15/12/23

how about
=IF(B2>TODAY(),DATEDIF(TODAY(),B2,"m"),DATEDIF(B2,TODAY(),"m"))


Book8
ABC
1
21/1/233
31/1/248
41/1/2520
51/1/2632
61/1/233
71/1/248
81/1/2520
91/1/2632
Sheet1
Cell Formulas
RangeFormula
C2:C9C2=IF(B2>TODAY(),DATEDIF(TODAY(),B2,"m"),DATEDIF(B2,TODAY(),"m"))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:B9Expression=AND($B2<>"",$B2<DATE(YEAR(TODAY())+1,MONTH(TODAY()),DAY(TODAY())))textYES
 
Upvote 0
ok, cross posted


for 2007, 2010 , 2013 , 2016 , 2019 or 365 Subscription excel version
Conditional Formatting

Highlight applicable range >>
A2:c100 - Change, reduce or extend the rows to meet your data range of rows

Home Tab >> Styles >> Conditional Formatting
New Rule >> Use a formula to determine which cells to format
Edit the Rule Description: Format values where this formula is true:
=AND($B2<>"",$B2<DATE(YEAR(TODAY())+1,MONTH(TODAY()),DAY(TODAY())))

Format [Number, Font, Border, Fill]
choose the format you would like to apply when the condition is true
OK >> OK

Book8
ABC
1
21/1/233
31/1/248
41/1/2520
51/1/2632
61/1/233
71/1/248
81/1/2520
91/1/2632
Sheet1
Cell Formulas
RangeFormula
C2:C9C2=IF(B2>TODAY(),DATEDIF(TODAY(),B2,"m"),DATEDIF(B2,TODAY(),"m"))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:C9Expression=AND($B2<>"",$B2<DATE(YEAR(TODAY())+1,MONTH(TODAY()),DAY(TODAY())))textYES
 
Upvote 0
So "=IF(B2>TODAY(),DATEDIF(TODAY(),B2,"m"),DATEDIF(B2,TODAY(),"m"))" is not conditional formatting is just function?
C= today()- B2. already a function on column C??!
 
Upvote 0
ok, your point , not following
you posted
and column C red flag including number of month, not number on C
Which i assumed was a question how to show the number of months in column C and not the number of days
otherwise i dont undertand at all

conditional formatting , has formatted Red column A, B & C based on the formula i posted , that the date is within a year of today

1. Does the conditional formatting WORK ?
if not why , please explain and
2. explain further the comment about months in column C
 
Upvote 0
Yes conditional formatting is working great. Thank you,. I really appreciate your help.
But Number of days in column C are =today() on column G2- B2.
 
Upvote 0
But Number of days in column C are =today() on column G2- B2.
ok, still not understanding
g2-b2
or
today()-b2
will give the number of days
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,877
Members
449,056
Latest member
ruhulaminappu

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