Set Numbers cell background color using AS with targeted cell based on selected cell

Modifying “Changing background colors of cells in mac numbers” that is here: Changing background colors of cells in ma… - Apple Community


Can this AppleScript be adopted to work with the current cell selected rather than the selection be based on a range?


Posted on Mar 22, 2023 11:15 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 22, 2023 01:59 PM

I thought I had misunderstood your question. Maybe the piece of code below will help to get you started. It replaces the first part of the code provided by SGIII (and it is basically from another script of his). It is a handy little snippet of code to have around when you want to write a script that does something to a selected range of cells.


tell application "Numbers"
	tell front document's active sheet
		tell (first table whose selection range's class is range)
			set selRange to selection range
			repeat with c in selRange's cells
				set c's background color to my hexColortoRGB("#143C23")
			end repeat
		end tell
	end tell
end tell


6 replies
Question marked as Top-ranking reply

Mar 22, 2023 01:59 PM in response to BernSh

I thought I had misunderstood your question. Maybe the piece of code below will help to get you started. It replaces the first part of the code provided by SGIII (and it is basically from another script of his). It is a handy little snippet of code to have around when you want to write a script that does something to a selected range of cells.


tell application "Numbers"
	tell front document's active sheet
		tell (first table whose selection range's class is range)
			set selRange to selection range
			repeat with c in selRange's cells
				set c's background color to my hexColortoRGB("#143C23")
			end repeat
		end tell
	end tell
end tell


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Set Numbers cell background color using AS with targeted cell based on selected cell

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.