Creating Dynamic Pop-Up Menus In Numbers With AppleScript

While it isn't possible to create dynamic Pop-Up Menus in Numbers alone, you can use an AppleScript service to pull data from one table, present it in a list that will then populate the value of a cell. You can set this service up with a keyboard shortcut to make data entry easier. The list will automatically update as you update the second table.

Here is the AppleScript code used in the tutorial.

on run {input, parameters}
	tell application "Numbers"
		tell table 2 of sheet 1 of document 1
			set options to {}
			set n to 2
			repeat while (n ≤ the number of cells of column 1)
				set option to the value of cell n of column 1
				set options to options & option
				set n to n + 1
			end repeat
		end tell
		tell front document's active sheet
			tell (first table whose selection range's class is range)
				tell selection range
					set c to first cell
					set mychoice to (choose from list options with prompt "Please choose" default items "None")
					set the value of c to mychoice
				end tell
			end tell
		end tell
	end tell
	return input
end run

Comments: 4 Responses to “Creating Dynamic Pop-Up Menus In Numbers With AppleScript”

    6 years ago

    So I followed the instructions in your last video, which worked well for me.

    I have re-named the tables in my Numbers document, so in your script, would I have to use my table name, or work out which table number to refer to?

    Thanks for a great series of videos, I’ve been watching for years.

    6 years ago

    Ian: Try them. It may work with both. To code and alter code like this you have to experiment. So try it each way.

    6 years ago

    Hi Gary,

    I worked it out, thanks for all your help 👍

    6 years ago

    Hi Gary,
    I have a Numbers document with numerous "sheets", and "tables" which need contact names entered in order to populate cells. The Script you provided enables the use of one dynamic name list that can be accessed by multiple sheets and tables throughout the document without having to use and change the "Pop Up" menu on each table.

Comments Closed.