AppleScript for Numbers would write to cells but not read
So basically I trying write an automated script to run some functions for me
here is what I need it to do
To iterate through all rows in the first table of the active sheet and check if the text in column F contains “win” or “loss”. If it does, it will replace the corresponding value in column G with 1 or -1.1, respectively. If it doesn’t contain either, it will replace the value in column G with 0. It will then iterate through each unique name in column A and sum up the corresponding values in column G. The total value for each individual will be placed in column H. Finally, it will multiply the total for each individual in column H by 100 and place it in column I.
Can anyone show me why I getting errors, I have included screenshot of the error as well as the model I am trying to replicate using apple scripts. I have no results.
Thanks for attention to this...
So far I wrote:
tell application "Numbers"
tell the active sheet of the front document
set lastRow to the count of rows of table 1
repeat with i from 2 to lastRow
set cellValue to value of cell ("F" & i)
if cellValue contains "Win" then
set value of cell ("G" & i) to 1
else if cellValue contains "Loss" then
set value of cell ("G" & i) to -1.1
else
set value of cell ("G" & i) to 0
end if
end repeat
set nameList to {}
repeat with i from 2 to lastRow
set nameValue to value of cell ("A" & i)
if nameValue is not in nameList then
set end of nameList to nameValue
end if
end repeat
repeat with i from 1 to count of nameList
set totalValue to 0
repeat with j from 2 to lastRow
set nameValue to value of cell ("A" & j)
if nameValue is equal to item i of nameList then
set totalValue to totalValue + (value of cell ("G" & j))
end if
end repeat
set value of cell ("H" & (i + 1)) to totalValue
set value of cell ("I" & (i + 1)) to totalValue * 100
end repeat
end tell
end tell
Finally, when I run the above script, I get an error
MacBook Air, macOS 14.0