YA Scripting Numbers AS question

I have a table with alternating row colors for football, where each game is listed on a row. I have three betters (one column per) and we put the team abbreviation for each pick in the corresponding column for each person. For any game where we disagree, all three columns are colored yellow so we can all tell what games to be concerned about. When the game is done, the “Winner” column’s abbreviation is compared against the better’s pick. Any losing cell has its background colored red and the winning cells have their background removed.

So here’s the question. Numbers AS support does not have a “No Fill” color option like its GUI does. Is the normal scheme of handling this type situation to query another side column for its background and copy that as the background for each winner cell? Or use some type of SystemEvents magic to choose the Cell sidepanel and pseudo-select the "No Fill" option from its Color pulldown for all selected winning cells in a single go?

Speed isn’t an issue as there are max 16 games per week.

You can tell a row to ‘clear’ to remove all contents and styles.

maybe copy text content, clear content, repopulate original text contents?

Sounds like clear range could work, but create a larger problem restoring all the other cells’ properties. Setting a cell’s background sounds much simpler.

Or am I missing something obvious?

A cell with ‘no fill’ as the background colour has a colour of ‘missing value’ in applescript. Unfortunately, you cannot set that as a colour. While you can set variables to missing value, that doesn’t help here. All this assumes that you don’t want to go with ‘white’ as the background.

So I would go with @paulskinner’s approach.

Take an example cell (ie one with a ‘no fill’ background) and set a variable to its properties. Then remove the background colour and name properties (and optionally, any of the others… probably the class). Get the cell’s value. Then clear the cell and set the properties and value.

tell application "Numbers"
	set w1 to window 1
	set d1 to document 1
	set s1 to sheet 1 of d1
	set t1 to table 1 of s1
	
	
	set selection range of t1 to cell "D3" of t1
	set sr to selection range of t1
	
	properties of sr
	--> {class:range, text wrap:false, text color:{0, 0, 0}, background color:{65535, 65535, 21706}, font size:10.0, alignment:auto align, font name:"HelveticaNeue", name:"D3:D3", format:automatic, vertical alignment:top}
	
	set propSr to {text wrap:false, text color:{0, 0, 0}, font size:10.0, alignment:auto align, font name:"HelveticaNeue", format:automatic, vertical alignment:top}
	set valueSr to value of cell 1 of sr
	
	clear sr
	set properties of sr to propSr
	set value of cell 1 of sr to valueSr
	
end tell

You could easily set up a loop and once you’ve entered in the ‘winner’, you could loop through the games and recolour (or decolour) all the yellow cells.

If you wanted to do something involving UI scripting, I’d go with the menu/keyboard commands Format > Copy Style and Format > Paste Style. Select a blank cell, copy style, select the appropriate yellow cells and paste style — all scriptable.