Apply conditional formatting to date, ignoring strikethrough

jlcm0924

New Member
Joined
Nov 26, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I'm working on a sheet with a Target date column, however once the target date has arrived / passed there can be a new Target date issued but I need to see that the original target date has been missed. Is there a way to apply conditional formatting using the date that does not have the strikethrough?
image001.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
Don't know if it can be achieved with a formula, but pretty sure it can be done with vba if you can make use of that. I imagine you are using Alt+Enter to add the second date on the next line in the cell? Could there ever be more than 2 dates in one cell?
 
Upvote 0
At first I intended to work with the strikethrough font but after a bit of thought I guess it doesn't matter if there are more than 2 dates if the code looks right to left for a linefeed character. So maybe this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim str As String
Dim intPos As Integer

If Not Intersect(Target, Range("N:N")) Is Nothing Then 'change to your date column
    str = Target.Value
    intPos = InStrRev(str, Chr(10)) + 1
    If intPos > 0 Then str = Mid(str, intPos) '>0 means there is a line feed character
    If CDate(str) > Date Then
        Target.Interior.ColorIndex = -4142
    Else
        Target.Interior.Color = vbRed
    End If
End If

End Sub
As always, test on a copy of your workbook. Enter cell values and move off of the cell (just hit Enter)?
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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