Question

Is is possible in Excel 2010 to set a conditional formatting rule to highlight all not empty cells in a row when the cell in particular column has a particular value?

I have a report in which every row identify a day. I would like to colour in grey the rows relative to Saturday and Sunday. The day is stored in column C.

I know how to highlight cells in column C, but how can I easily extent the format of cell C to the adjacent not empty cells in the same row?

Was it helpful?

Solution

This is easy to do without a macro and without using INDIRECT function

Assuming you have data starting at row 2 and that the "day" in column C is a text value then do this:

Select whole range of data, e.g. A2:J100

apply in conditional formatting the formula that needs to apply to the first row, e.g.

=AND($C2="Saturday",A2<>"")

That will apply formatting to all cells in the range if col C of that row is "Saturday" and the cell itself is not blank. Note C2 needs a $ in front because it applies to C for the whole row A2 doesn't need $

If you want to apply to Saturday and Sunday the same type of formatting then use an OR, i.e.

=AND(OR($C2="Saturday",$C2="Sunday"),A2<>"")

....or if the column C entries are actual dates make that

=AND(WEEKDAY($C2,2)>5,$C2<>"",A2<>"")

See example workbook with that last CF formula demonstrated

OTHER TIPS

Taking inspiration from John answer in this thread, I've used the "indirect" function on the conditional formatting.

  1. Select Conditional Formatting
  2. Select New Rule
  3. Select "Use a Formula to determine which cells to format"
  4. Enter the Formula, =WEEKDAY(INDIRECT("c"&ROW()))=1 # for Sundays
  5. Enter the Format you want (text color, fill color, etc).
  6. Select OK to save the new format
  7. Open "Manage Rules" in Conditional Formatting
  8. Select "This Worksheet" if you can't see your new rule.
  9. In the "Applies to" box of your new rule, enter =$A$1:$J$35 (or however wide/long you want the conditional formatting to extend depending on your worksheet)
  10. Do it again, this time inserting the Formula, =WEEKDAY(INDIRECT("c"&ROW()))=7 # for Saturdays

There is only an issue with this formula. When the cell in Column C is empty it will be read as 7, therefore the row will be formatted as if it's a Saturday. Do you know why?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top