In Calc I have column with a series of calculated dates (ie. the result
of a formula). I am looking to find a way of using conditional
formatting to set the background colour (eg. green) for those dates
which fall on a Saturday or Sunday (eg. Condition: = WEEKDAY (A2; 2)>5
sets Format: Cell Background = Green)
Can anyone offer any pointers to a solution?
TIA
Dave
Dave Barton wrote
In Calc I have column with a series of calculated dates (ie. the result
of a formula). I am looking to find a way of using conditional
formatting to set the background colour (eg. green) for those dates
which fall on a Saturday or Sunday (eg. Condition: = WEEKDAY (A2; 2)>5
sets Format: Cell Background = Green)
Can anyone offer any pointers to a solution?
One way to do this is to have another column with column Weekday using the
formula you suggested. Then you have two options: either use conditional
formatting to set the background of the Weekday column OR use conditional
formatting with Condition set to "Formula is" and point to the weekday in
the same row and have the background changed accordingly.
Hope this helps
Pedro
Try =ISTEXT(A2) first.
I think you have (almost?) answered your own question.
o Select *one* cell of your range - e.g. your A2.
o Go to Format | Conditional Formatting... .
o With "Condition 1" ticked, select "Formula is".
o In the Cell Value Condition box, enter: WEEKDAY(A2;2)>5
o For Cell Style, select Green. You need either already to have defined a "Green" cell style or else to create one on the fly using the New Style... button.
o Now copy that formatting to other cells in your range. You can do this either by using the Format Paintbrush or by copying A2 and pasting it over the range, but using Paste Special... and selecting *just* Formats in the Paste Special dialogue.
Alternatively there is a quite different technique using the STYLE() function. Modify your original formulae to read:
=<your existing formula>+STYLE(IF(WEEKDAY(CURRENT();2)>5;"Green"))
I trust this helps.
Brian Barker
Yes, Thank you Brian. I knew where I wanted to go, but took a wrong turn
and got lost. I now have no idea why I missed the obvious.
Also, thanks for reminding me about the "+STYLE(IF" alternative.
Guess I was having a brain deadlock day.
Regards
Dave
It works also with a range selection or even with multiple selected
ranges as long as you are aware that the dialog shows the conditional
format of _one_ cell which is the currently active cell within the
current range selection. All relative references are relative to this
single cell and adjust to the other cells when you finish the dialog.
The relative references in a c.f. behave exactly like in a cell formula
which is entered into a range of cells using Alt+Enter.
Test: Select a column of cells, say X1:X5, type =Y1 and hit Alt+Enter.
The c.f. dialog behaves in the same way in respect to the active input
cell and the other selected cells.