Newbie here, I need to run a macro to highlight a date if it is before today.

cochrajl

New Member
Joined
Sep 19, 2014
Messages
27
I'm not sure what other information you need, but I need to run a macro to automatically highlight a date in red in column J if it is past due. Any help will be appreciated.
 

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
Can't help you with macros, but you could use Conditional Formatting to highlihgt it. This is what I did.

highlight the column you want to use. Go to conditional formatting. Click New rule. Click format only cells that contain. In the dropdown, choose less than or equal to. In the next box, put TODAY(). That will highlight all cells that are less than today.
 
Upvote 0
Code:
Sub HIGHLIGHTTHECELLS()

    For x = 1 To Cells(Rows.Count, "J").End(xlUp).Row
        If Cells(x, 10) < Date Then
            Cells(x, 10).Interior.Color = vbRed
        End If
    Next x
        


End Sub
 
Upvote 0
I thought about using conditional formatting, but the range is going to change daily. I need a macro to run on the cells that contain values.
 
Upvote 0
Thanks for the quick reply! How can I manipulate this to just highlight the text red, and to not highlight blank entries?
 
Upvote 0
Code:
Sub HIGHLIGHTTHECELLS()


    For x = 1 To Cells(Rows.Count, "J").End(xlUp).Row
        If Cells(x, 10) < Date Then
            Cells(x, 10).Font.Color = vbRed
            Cells(x, 10).Font.Bold = True
        End If
    Next x
        


End Sub

Red font color and bold.
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,151
Members
449,068
Latest member
shiz11713

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