I'm trying to write a numbers script (to do this, as it happens), in which I need to change the value of a cell.

However, if I do something like

tell application "Numbers"
    tell document 1
        tell sheet 3
            set the value of cell "E1" to 1000
        end tell
    end tell
end tell

then I get the error

 error "Numbers got an error: Can’t set cell \"E1\" of sheet 3 of document 1 to 1000." number -10006 from cell "E1" of sheet 3 of document 1

but this contains no information about why it can't set that cell. The document, the sheet and the cell all exist.

I guess this might depend on my particular spreadsheet, but is this the correct way to set the value of a cell, and if so, what else can I do to understand why it's not working?

  • I'm thinking what you have should work, but I’m not in front of a Mac at the moment, so can’t have a play with this. If someone else doesn't chime in before I'm back in front of a Mac, I'll test at my end. I'm pretty sure that the error code you're getting refers to being denied write permissions to the file. Is there anything that may explain why you'd be denied permission to set the value? Is Numbers running? Is the spreadsheet already open? Something else?
    – Monomeeth
    May 16, 2018 at 7:10
  • @Monomeeth thank you for looking into it. The file exists and is open in Numbers. It is currently the frontmost document, and is saved in a subfolder of my Documents folder, where there should be no issues with file permissions.
    – N. Virgo
    May 16, 2018 at 8:41
  • (One thing though is that there are many other unsaved documents currently open, which I don't want to save or close currently. My understanding is that "document 1" always refers to the frontmost window, but I can't actually find that stated in any documentation, and if I'm wrong I suppose it might be trying to set a cell in one of the other documents.)
    – N. Virgo
    May 16, 2018 at 8:42
  • Hmm, I get similar errors trying to get the file name of document 1, or trying to get the value of cell A1 in sheet 1. So I guess the problem is with accessing document 1 at all.
    – N. Virgo
    May 16, 2018 at 8:51
  • e.g. error "Numbers got an error: Can’t get cell \"A1\" of sheet 1 of document 1." number -1728 from cell "A1" of sheet 1 of document 1 (I'll edit all this into the question later)
    – N. Virgo
    May 16, 2018 at 8:51

2 Answers 2


I'm in front of a Mac again and gave your code a go and also got the same error, so it's probably somewhat misleading in terms of what it actually means.

However, I did play around with your script a bit and was able to get the code to work by using the following code:

tell application "Numbers"
  tell table 1 of sheet 3 of document 1
    set the value of cell 1 of column "E" to 1000
  end tell
end tell

However, now that I've got this to work, I just wanted to flag you seem to be hard coding the cell etc. That is, if the position changes then the script isn't going to be dynamic. Whether this is an issue for you or not will depend on what you're trying to do and how your Numbers spreadsheet is designed.

  • Hurrah! Yes, that works - evidently specifying the table is the necessary step that I had missed.
    – N. Virgo
    May 16, 2018 at 11:48
  • (This is a quick hack that definitely doesn't need to work after tomorrow, otherwise I would be doing this properly instead of hard coding. So thanks for the quick answer, it will make a big difference and is much appreciated!)
    – N. Virgo
    May 16, 2018 at 11:49

Do it with a one-liner. Don't need nested tell.

tell application "Numbers" to set document 1's sheet 1's table 1's cell "E1"'s value to 1000

Or a more generic solution of:

set documentName to "Document 1"
set sheetName to "Sheet 1"
set tableName to "Table 1"
set cellName to "D1"
set newvalue to "2000"

tell application "Numbers" to set document documentName's sheet sheetName's table tableName's cell cellName's value to newvalue

You must log in to answer this question.

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