applescriptautomatoriwork

Using AppleScript, how to set the value of a cell of the Numbers App/iWork file


Using the numbers file below, how do i set a value into cell B2?

enter image description here

The hard part is that i cannot use any of the code below:

set the value of cell 2 of column "B" to "200.00"

or

set the value of cell "B2" to "200.00"

Based on the requirements, i have to find the row and the column because their positions can change.

I have got this part to work:

set the value of cell 2 of column of (first cell of row 1 whose value is "SUM") to "200.00"

Now I'm trying to get rid of the cell 2 in the code above. I can't figure it out. Any help will be much appreciated.


Solution

  • You can use the header's name like this :

    tell application "Numbers"
        tell table 1 of sheet 1 of document 1
            set colIndex to address of column "SUM"
            set value of cell colIndex of row "Jan" to "200.00"
        end tell
    end tell