Highlight line question

kerm007

Active Member
Joined
Mar 16, 2019
Messages
267
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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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