Script Editor

I have previously used Script Editor without any problem when updating my monthly accounts spreadsheets ie:

  1. placing cursor next to where I wish to change the month
  2. selecting Script Editor
  3. selecting > run
  4. selecting the month required "Nov"
  5. watching all the relevant sheets update accordingly


On my latest attempt just now - intending to change this tear's sheets to "Oct":


Stages 1 - 4 as per above then ..... nothing or, in this case Finance Statement 2025/- Oct (which is not the format I want)


Anyone any thoughts as to what I'm not doing or what might have changed please?

MacBook Pro 14″

Posted on Oct 30, 2025 8:02 AM

Reply
7 replies

Oct 31, 2025 4:24 AM in response to PaulSG

If the month is always a three character abbreviation at the end of each table name then you can simplify the script to something like this:


(be sure to copy the whole thing including parts that are hidden to the right)


set newMonthName to (choose from list {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Sep", "Oct", "Nov", "Dec"}) as text

tell front document of application "Numbers"
	repeat with s in sheets
		tell s
			set oldTableName to name of table 1
			set name of table 1 to text 1 thru -4 of oldTableName & newMonthName
		end tell
	end repeat
end tell



SG

Oct 30, 2025 2:42 PM in response to PaulSG

I typed in most of your script and it worked fine for me.


I am trying to figure out what result you are getting. You mentioned "Finance Statement 2025/- Oct" as one bad result, "Finance Statement 2025/26 - ??" as another bad result, and "Finance Statement 2024/25 - Nov" as being okay. If these are all for the same table, I don't understand how the years changed or why the first one lost the second year (presumable "26") and the space before the "-" or where the question marks came from in the second one.


What was the original table name? I assume it ended in "Sep" but I don't want to be assuming anything when things are not making sense.


Your steps say you "[place the] cursor next to where I wish to change the month". Why do you do that? All you need to do is have the document open and up front. Your script changes the title of the first-created table of each sheet.



Nov 1, 2025 8:46 AM in response to PaulSG

PaulSG wrote:

Many thanks Badunit.

SGill - dumb quest possibly but can I copy and paste into Script Editor or better to type exactly as shown (inc colours)?


If you carefully select all of the script including what's scrolled out of sight then you should be able to just copy-paste into Script Editor. No need to retype. Script Editor will color as it sees fit.


I usually File > New in Script Editor and paste a script in that document, then run that new one on a duplicate of my document until I'm sure it's doing what it's supposed to.


That way, the originals are still there if something goes wrong.


SG

Oct 31, 2025 4:36 AM in response to Badunit

Thank you all for your constructive responses - much appreciated.


To answer you Badunit:

Finance Statement 2025/- Oct was a bad result as I wanted to get the same as my previous spreadsheets, ie

Finance Statement 2024/25 - Nov which is on a different, completely separate, spreadsheet (last year's).


I only added the ?? marks in there in my post as nothing had appeared, ie all I got was

Finance Statement 2025/26 -


Ref my placement of the cursor - that was only after it hadn't worked first time around; like you, I normally hadn't paid any heed to the position of the cursor.


I'll wait to hear back from you before I mess with any adaptation to the script!


Thanks again

Script Editor

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.