Highlight line question

kerm007

Active Member
Joined
Mar 16, 2019
Messages
250
Office Version
  1. 365
Platform
  1. Windows
Hello
i have a code that highlight cell (B,C,D,E.F ) in green

VBA Code:
Sub MyFormat()

    Dim rng As Range
    Set rng = Range("B5:F700")

    With rng
        .FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=AND(COUNTIF($B5:$F5,54)>0,COUNTIF($B5:$F5,9)>0)"
        .FormatConditions(.FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = RGB(0, 128, 0)
            .TintAndShade = 0
        End With
        
        .FormatConditions(1).StopIfTrue = False
        .FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=AND(COUNTIF($B5:$F5,3)>0,COUNTIF($B5:$F5,9)>0)"
        .FormatConditions(.FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = RGB(0, 128, 0)
            .TintAndShade = 0
        End With
        
        .FormatConditions(1).StopIfTrue = False
        .FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=AND(COUNTIF($B5:$F5,5)>0,COUNTIF($B5:$F5,6)>0)"
        .FormatConditions(.FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = RGB(0, 128, 0)
            .TintAndShade = 0
        End With
        
        .FormatConditions(1).StopIfTrue = False
        .FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=AND(COUNTIF($B5:$G5,8)>0,COUNTIF($B5:$G5,10)>0)"
        .FormatConditions(.FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = RGB(0, 128, 0)
            .TintAndShade = 0
        End With
        
        .FormatConditions(1).StopIfTrue = False
    End With

End Sub


my question is how can expand the code to highlight also the cell G

Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Very basic question, have you tried changing ALL the references to F5 to G5 and F700 to G700?
The repeated appearance of F5 in the code when you wanted to include "cell G" simply suggest to me that you need to change "F5" to "G5"
Make those alterations and see what you get.
 
Upvote 0
i trie4s to change it but it still high light only B,C,D.E.F
i have another macro that highlight in red when the number of the player have an H next to is number
maybe because of that ?

1693071241594.png



maybe i can add something to my round robin code to avoid certain player to play against some other ?
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,096
Latest member
provoking

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