Home > Forum Home > Presenting and Reporting Data > Conditional Formatting Multiple 'IF Thens' With Specified Colors Share

Conditional Formatting Multiple 'IF Thens' With Specified Colors

Excel Help for Conditional Formatting Multiple 'if Thens' With Specified Colors in Presenting and Reporting Data


Forum TopicPost Reply Login

Conditional Formatting Multiple 'if Thens' With Specified Colors

Rate this:
(3/5 from 1 vote)
ConfusedQuite simply, I would like to sort and filter names and dates (in specified colors given the specified dates).

What has taken me four days to figure out will likely take someone in this forum seconds.

I am very new to all of this, and I come modestly, respectfully, and appreciative for any help.
I have a few questions, but they are all connected, and with a few short answers I can have my entire sheet functioning beautifully.

Conditional formatting is the most simple way to do this.  However, I have a =ColorFunction sub that conditional formatting would interfere with (because it is my understanding the “=ColorFunction” does not recognize colors highlighted conditionally (or with private subs either).  For this reason, I have thrown together an alternative sub macro that creates the same result that my colorfunction formula could recognize.

VBA Code:
Sub Highlight_Date_Today_Red()

'searches finds and highlights today date in range in a specified color without the use of standard conditional formatting

' Highlight_Date_Today_Red Macro
Range("E4:E1000").Select
    Application.FindFormat.Clear
     'On Error Resume Next
Cells.Find(What:=DateValue(Today), After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

        With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
End Sub

It worked but it only highlighted one cell.  Sad for me, and yes it is okay to laugh at my code (but at least give me credit for attempting this Frankenstein monstrosity) Lol

Here are my four questions:

How do I get it to search and highlight the current date today throughout the entire column accordingly?

As for multiple values, how would I get it to highlight yesterday’s date in another the color the same way accordingly?

Next, how would I write this same code with something along the lines of:

If Range(“H4”) contains “/”, then highlight cell (“E4”) in this color?

Finally,

If Range(“H4”) contains no fill color, then highlight cell (“E4”) in this color?


Any help on this would be super extremely appreciated you have no idea.  I tried so many variations from so many forums for so long that it’s time I sought help from someone.  Anyone who can help me this will have a speedy response from me guaranteed.  I will be monitoring any responses round the clock.  Thanks in advance.

Quick note:  I did make sure the dates I attempted to find and highlight were formatted as “date cells” and not “text cells”.
 Posted by on
 
Replies - Displaying 1 to 1 of 1Order Replies By: Most Recent | Chronological | Highest Rated
Happy
Rate this:
(3/5 from 1 vote)
The following VBA macro will highlight today's date and yesterday's date. Of course it can be improved such as condtions modified and added as well as the formatting options.
VBA Code:
Sub highlightdates()
Application.ScreenUpdating = False
Dim c As Variant
For Each c In Selection
    MsgBox Now() - c.Value
    'Today
    If Now() - c.Value <= 1 Then
        c.Select
        With Selection.Interior
            .ColorIndex = 8
            .Pattern = xlSolid
        End With
    End If
    'Yesterday
    If Now() - c.Value > 1 And Now() - c.Value <= 2 Then
        c.Select
        With Selection.Interior
            .ColorIndex = 6
            .Pattern = xlSolid
        End With
    End If
Next
Application.ScreenUpdating = True
End Sub
 Excel Business Forums Administrator
 Posted by on
 Displaying page 1 of 1 

Find relevant Excel templates and add-ins for Conditional Formatting Multiple 'IF Thens' With Specified Colors in the