How do I format the color of a cell based on the criteria of the cell to the right of it?

bananius

New Member
Joined
Aug 27, 2014
Messages
8
I am trying to write a macro, which, when a date value is entered into one cell, 10 days after that date it will change the color of the cell to the right of it a shade of red.

This is what I have so far, but it's not working. Can anyone point out what I am doing wrong? Thank you!!!

Code:
Sub Colouring()
Dim TodayDate As Date
Dim cell As Range
TodayDate = Day(Now)
    For Each cell In Range("D8:D67, G8:G67, J8:J67, M8:M67, P8:P67, S8:S67, V8:V67, Y8:Y67, AB8:AB67, AE8:AE67, AH8:AH67, AK8:AK67, AM8:AM67, AP8:AP67, AS8:AS67, AV8:AV67, AY8:AY67, BA8:BA67, BD8:BD67, BG8:BG67")
        If TodayDate = cell.Value + 10 Then
            With rCell.Offset(1, 0)
            cell.Interior.ColorIndex = RGB(255, 199, 206)
            cell.Font.ColorIndex = RGB(156, 0, 6)
        End If
 
Next cell
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Day function:
The Microsoft Excel DAY function returns the day of the month (a number from 1 to 31) given a date value.

Maybe what you want is TodayDate=Date()
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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