If date in cell is older than todays date by 1 month Then Font RED

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,649
Office Version
  1. 2007
Platform
  1. Windows
Hi,
On my worksheet in column H i have dates of when i quoted for a job.
My goal is to check each date with todays date & if more than 1 moth old have that rows Font vbRed.

So my setup is like this.
Headers in Row 1
Dates are all in column H
Values start Row 2 & down the page.
Cells in use are column A to L
Worksheet is called QUOTES

So when the worksheeet QUOTES is open the code will run.
The code will check the date in column H with todays date.
Any date that is older than 1 month will have that rows cells Font changed to vbRed
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Any reason not to just use Conditional Formatting?

24 10 15.xlsm
ABCDEFGHIJKLM
1Quote Date
27/10/2024
319/09/2024
46/09/2024
510/09/2024
618/09/2024
77/10/2024
89/09/2024
94/09/2024
10
11
126/09/2024
1325/09/2024
144/09/2024
1512/09/2024
1615/10/2024
177/09/2024
1820/09/2024
19
2025/08/2024
QUOTES
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:L20Expression=AND($H2<EDATE(TODAY(),-1),$H2<>"")textNO
 
Upvote 0
I have tried the following but it has no affect at all ?

Do you see why that may be

VBA Code:
If Sheets("QUOTES").Range("H2").Value > DateAdd("m", 1, Date) Then
Range("A2:L2").Font.Color = vbRed
End If
 
Upvote 0
Try some code to filter the data based on column H using your criteria and then set the color for the visible range to red then remove the filter.
 
Upvote 0
Perhaps you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here (de-sensitized if necessary).
 
Upvote 0
I would like to continue with it myself to see how i get on but do you see an issue with the code i have supplied,looking at it i see it should work but makes no difference
 
Upvote 0
Using the AutoFilter approach an option might be

VBA Code:
Sub ApplyRed()
  Application.ScreenUpdating = False
  With Sheets("QUOTES")
    .AutoFilterMode = False
    With .Range("A1:L" & .Range("H" & Rows.Count).End(xlUp).Row)
      .AutoFilter Field:=8, Criteria1:="<" & CLng(DateAdd("m", -1, Date)), Operator:=xlAnd, Criteria2:="<>"
      If .Columns(1).SpecialCells(xlVisible).Count > 1 Then .Offset(1).Resize(.Rows.Count - 1).Font.Color = vbRed
    End With
    .AutoFilterMode = False
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,636
Messages
6,167,221
Members
452,104
Latest member
jadethejade

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