How to Highlight Each Column-Heading of the Active Row When The Corresponding Cells Contain 'X'

Eduard_Stoo

New Member
Joined
Apr 15, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi -

I have a list of company plant and would like to dynamically-highlight the column title as each active row is selected, based on that row containing an 'X'.

I've kind of got part-way there, but can't get it over the line... It works for the first line highlighted in the set, but nothing after that

Screenshot 2024-11-12 082416.jpg


The conditional format formula in the header row T1:AB1 is currently : =IF(AND(CELL("row")=ROW(T3)),T3="X"). I need to expand to incorporate the entire list, but not sure of the best methodology... they may be a simpler solution also! I would appreciate if anyone can guide me on this one! Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi Eduard, the main issue with that function: CELL("row") doesn't update when you select a cell, but only after you click in a cell in that row. Try this formula, that does work:
Excel Formula:
D1: =IF(AND(CELL("COLUMN")=COLUMN(D1)),CELL("contents")="X")
 
Upvote 0
This is what I think you are asking.
  • Select T1:AB1 and apply this Conditional Formatting formula & apply your colour formatting
    =OFFSET(T1,CELL("row")-1,0)="x"

  • Right click the sheet's name tab and choose 'View code' and paste this code.
    VBA Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      Application.ScreenUpdating = True
    End Sub
Here is my sheet when any cell in row 2 is selected (happens to be S2 in this case)

1732185993993.png


Here is my sheet when any cell in row 3 is selected (happens to be W3 in this case)

1732186070511.png


Is that the sort of thing you are after?
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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