1

I do several mundane repetitive tasks using Numbers App on a Mac, and wish I could just automate the same with the help of AppleScript.

I got Numbers Spreadsheet with several tables, on the selected table, I want the script to run through all rows of selected column (which is column 1 mostly) and format cells (color the text blue or red) depending on even or odd value condition.

thanks

  • Hey, welcome to Apple.SE! Yes it is possible to automate actions in Numbers. But as a general convention, asking a question here, is supposed to be last step with all attempts of solving the problem in it. If you learn a bit about Automation and Scripting, it would be easier for answerers to help you in your code and so far I've seen, Debugging shows more enthusiasm from the people here than in script writing . macmost.com/using-applescript-to-automate-in-numbers.html and raywenderlich.com/… – ankii Jul 31 at 13:29
  • I did try with a script to the needful. but I am exhausted getting past ranges and repeats. and lack of examples with regards to numbers & iWork. further, apple didn't do any good by naming the spreadsheet app as "Numbers", makes it so much more difficult to get relevant results. – Savin Jul 31 at 17:05
2

I finally got what I wanted. I used an app called Script Debugger 7, though not necessary, it really helped me with all the classes & options available with each application and detailed help.

Further, it was really easy to write scripts in this app. For anybody needing a similar solution, I hope this helps. This script is not the best, in terms of error checking or dynamic names, but that's for another day.

------Script below--------

property rBlue : {1721, 15020, 27788}
property rPink : {48626, 3448, 26715}

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions


tell application "Numbers"
tell document 1
    tell active sheet
        tell table "Table 1"
            set rCount to get row count

            repeat with r from 2 to rCount
                set valCell to formatted value of cell ("A" & r)
                set remCell to valCell mod 2

                if remCell = 0 then set text color of cell ("A" & r) to rBlue
                if remCell ≥ 1 then set text color of cell ("A" & r) to rPink
            end repeat

        end tell
    end tell
end tell

end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .