If I understand correctly you want to color the entire row yellow if the value column in D is 1, gray if 2, orange if 3, blue if 4.
If that is is correct, then the script below will do that.
- Copy-paste into Script Editor.
- Click once in any cell of the target table (the one where you want to highlight the rows) to activate the table.
- Click the green triangle 'run' button in Script Editor.
The results will be something like this:
As you will note, unlike VBA in Excel, AppleScript is "external" to Numbers. You can't attach the script to a button within Numbers but you can easily make it a menu pick by clicking 'Show Script menu in menu bar' in Script Editor's Preferences > General:
Then you can click on the icon that looks like a "scroll" at the top of your screen to open the Scripts Folder and move the script into there, where it is easily accessed when you need to run it. If needed you can also place the script into an Automator Service that will appear in your Numbers > Services menu and attach a keyboard shortcut via System Preferences > Keyboard > Shortcuts > Services. If need more details on that, just ask.
If for some reason your script just "isn't doing anything" check to be sure Script Editor is checked here:
And after clicking give it some time. AppleScript, though convenient, is no speed demon, and 8000 is a lot of rows.
If you run into problems just post.
SG
set testCol to 4 -- column D
set theColors to {"yellow", "gray", "orange", "blue"}
-- order here is significant: yellow if value is 1, gray if 2, etc. -- and have a color for every possible value in D
tell application "Numbers"
tell document 1 to tell active sheet
set t to first table whose class of selection range is range
repeat with i from 2 to count t's rows -- from 2 to skip Header Row
tell t's row i
set v to its cell testCol's formatted value
if v is not missing value then
set its background color to theColors's item v
end if
end tell
end repeat
end tell
end tell