Hi. I’m working on a script to clean up an Apple Numbers file. It is working but I was thinking it can be better in one point: avoid repeating the same thing for every item. Let me explain:
-
I have some cells as categories:
set value of cell “H8” to “Food”
set value of cell “H9” to “Shopping”
set value of cell “H10” to “Taxes”
(go like this for 22 rows) -
I have some pre-define colors for them:
set ColorFood to {65535, 65535, 43690}
set ColorShopping to {65535, 64250, 52685}
set ColorTaxes to {65535, 60138, 52942}
(go like this for 22 rows) -
Each one has a color:
set the background color of range “H8:I8” to ColorFood
set the background color of range “H9:I9” to ColorShopping
set the background color of range “H10:I10” to ColorTaxes
(go like this for 22 rows) -
Later I check some cells and if they contains some text, it add a value to the next column and change the color:
if theText starts with “DEB AUTOR” then
set value of cell thisRangeCategoria to “Food”
tell cell thisRangeCategoria
set the background color to ColorFood
end tell
end if
(go like this for 22 items)
I was trying to create a handler to pass all the values at once, but I got stuck. Is there a way to say: "okay, check “theText”, if it is “Food”, add the color for Food items and say “Food” in the next column.
As I said, it is working as I did, but maybe it can be made in a more smart way.
Any suggestion?
Thank you!