conditional formatting

biglb79

Active Member
Joined
Oct 17, 2007
Messages
299
is there a way I can have a specific row highlight in red if one cell in that row has an X in it? for example, if someone types X in cell N2, I want A2:K2 to highlight in red, and then I'll copy/paste special formulas down to other rows
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi,

Assuming you mean something like if N2:Q2 has X, highlight A2:K2

CF, use formula:

=COUNTIF(N2:Q2,"X")
 
Upvote 0
I can't get it to work. do I highlight cells A2:K2 then go to conditional formatting>new rule>use formula to determine which cells to format then type the rule in and click on the fill color?
 
Upvote 0
Can formatting be done via a formula? Haven't heard of it...
Would a macro work? If N2 contains an "X" then fill A2:K2 with red, if not, remove fill.

Code:
Sub CheckN2()
    Range("n2").Select
    vN2 = ActiveCell.Value
    Range("A2:K2").Select
    If vN2 = "x" Or vN2 = "X" Then
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 255
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    Else
        With Selection.Interior
            .Pattern = xlNone
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    End If
End Sub
 
Last edited:
Upvote 0
thanks! is there a way to edit that macro so that I can use it on all rows? it's always going to be column N that would have the x and columns A:K that would be highlighted
 
Upvote 0
Apologies, left out absolute referencing, should be:

=COUNTIF($N2:$Q2,"X")
 
Upvote 0
Can formatting be done via a formula? Haven't heard of it...

You haven't heard of the Native Excel feature of "Conditional Formatting" aka CF?

Home tab, near middle of Ribbon, "Conditional Formatting"
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,292
Members
448,885
Latest member
LokiSonic

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