conditional highlight an entire row?
Numbers 3.6.2
El Capitan 10.11.6
I'd like to highlight an entire row based on the content of a single cell in this row. Advice?
MacBook Pro (Retina, 15-inch, Early 2013), OS X El Capitan (10.11.6)
Numbers 3.6.2
El Capitan 10.11.6
I'd like to highlight an entire row based on the content of a single cell in this row. Advice?
MacBook Pro (Retina, 15-inch, Early 2013), OS X El Capitan (10.11.6)
HI fiasko,
Conditional highlighting rules apply to individual cells, and require comparing the content of the individual cell to either a fixed value or the value in another cell.
To highlight whole rows using conditional highlighting requires using one of two techniques:
Note that this rule fails with an empty cell due to the copy containing a zero. Probably preventable with some formula tweaking.
The "copy" table would be hidden in this method.
Both of these methods are 'live' and provide 'instant updates.
A disadvantage is the need to edit two tables when there is a change in the number of rows in the original.
Regards,
Barry
Thank you, Barry.
Your solution(s) will certainly help me in situations where I've a fixed number of rows. Unfortunately, the situation I am currently in finds me constantly adding rows to the bottom of the table. I am logging data on a daily basis.
I may use your solution(s) to highlight my rows weekly or monthly.
If a solution pops up that will work using only one table, so that I can keep adding rows, I will be delighted to receive the news.
All the best,
MW
HI MW,
I'm sure there is an AppleScript solution that can accomplish this without the use of a second table. The disadvantage with using a script or an Automator service is that the user has to manually trigger the script to update the highlighting.
A quick search on 'highlight row' brought up several hits, including this question Re: Conditional Highlighting for entire rows from late 2014.
There are two scripts in the thread. SGIII's is the more direct, the other looks like an interesting experiment, but may be less practical.
Here's my test table "original" with the conditional highlighting rule removed.
SGIII's script (edited to match the column and 'testValue' used in my table) was run before adding the adding the "yes" to D7.
After adding "yes" and running the script again:
Regards,
Barry
OOPS!
Just noticed a shortcoming of that particular script—it only works in one direction, applying the fill colour to a row containing a match to the test value.
Unfortunately, it doesn't remove that fill if run later when the test value is no longer in that cell, and can be seen here, where the script was run again after deleting "yes" from D3 and D7, and added to D9.
Here's an amended version of SG's script from the linked thread.
The revisions solve the 'unhighlighting' issue but leave another related issue discussed below:
As can be seen, the rows no longer containing yes are no longer highlighted...BUT
The original colour fill on the header row and header column has also been replaced, either by the hilight colour or by the 'lolight colour (white), masking the fact that these are headers,
and the unhilighted cells now have a colour fill (white) applied where before they had "No fill".
Here is the edited script. SG may have additional changes.
--highlight a row based on value found in column testColumn on that row
--Script by SGIII
--additions by Barry
property testColumn : 4 -- 1 is column A, 2 is column B, etc (changed to match example)
property testValue : "yes" -- changed to match example
property highlightColor : "red"
property lowlightColor : "white" -- added property. colour for unhighlighted rows B
tell application "Numbers" to tell front document to tell active sheet to tell (first table whose class of selection range is range)
repeat with r in rows
set v to r'scelltestColumn'svalue
if v is testValue then set r'sbackground color to highlightColor
if v is not testValue then set r's background color to lowlightColor -- added line B
end repeat
end tell
Regards,
Barry
conditional highlight an entire row?