Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How do I link a Table in Apple Numbers?

When you right click any text, you have the option of linking Webpage, E-mail, Phone Number and Sheet. But, there is no option of linking Tables.


I have multiple tables in a single sheet. I created Text boxes for each table at the top of the sheet. I want to go to that table by clicking those text in the textbox. How do I do that?

MacBook Air 13″, macOS 11.2

Posted on May 3, 2021 2:43 AM

Reply
6 replies

May 8, 2021 5:51 AM in response to pheonix2610

If your sheets are listed in cells of a table, not in a text box, with scripting you can select the cell that has the table name then use a keyboard shortcut to invoke the script that takes you to that table. It is not a single "click and go" but it's the closest I can think of.


The script below requires the selected cell to have a sheet and table name in it, as text (such as Sheet 1::Table 1). It also lets you specify a specific cell (such as Sheet 1::Table 1::B1) if you want to go that far. It jumps to cell A1 if none is specified. It is best if it jumps to a cell that is blank or has text in it. You cannot jump to a cell that has a formula in it, it will overwrite the formula with its current value. That problem can be fixed I think. It could also be modified so it requires only the table name and jumps to tables only on the current sheet.


You can try it out by starting up the Script Editor app and pasting this into a new window. Click on a cell in your Numbers document that has a sheet and table specified (as described above) then go back to Script Editor and press the "Play" button to run the script.


tell application "Numbers" to tell front document
	activate application "Numbers"
	tell active sheet
		tell (first table whose class of selection range is range)
			set newFocus to my splitText((value of first cell of selection range), "::")
		end tell
	end tell
	
	set thesheet to item 1 of newFocus
	set thetable to item 2 of newFocus
	if number of items of newFocus = 3 then
		set thecell to item 3 of newFocus
	else
		set thecell to "A1"
	end if
	
	set value of cell thecell of table thetable of sheet thesheet to value of cell thecell of table thetable of sheet thesheet
	
end tell

on splitText(theText, theDelimiter)
	set AppleScript's text item delimiters to theDelimiter
	set theTextItems to every text item of theText
	set AppleScript's text item delimiters to ""
	return theTextItems
end splitText

May 8, 2021 7:42 PM in response to Badunit

Scanning through my "Numbers Forum" folder on one of my computers looking for something else, I ran across a script that jumps to a specified cell in a better way. I modified it to allow specifying just a sheet and table. I'm sure the original script came from someone else but I don't know who. Interestingly the one I wrote a few days ago came out looking much the same.


-- Goto Numbers Cell
-- In a cell in a table will be text of the form sheetname::tablename::cellname
-- such as Sheet 1::Table 1::D4
-- Select the cell then run the script and the focus should move to the specified cell.
-- Alternatively, the cell may contain sheet and table name without the cell name
-- such as Sheet 1::Table 1
-- In this case the focus will move to cell A1 of the specified table



tell application "Numbers"
	tell front document
		tell active sheet
			tell (first table whose selection range's class is range)
				set linktext to (value of first cell of (selection range)'s cells as text)
			end tell
		end tell
		
		set myArray to my theSplit(linktext, "::")
		
		set active sheet to sheet (item 1 of myArray)
		tell active sheet to tell table (item 2 of myArray)
			if number of items of myArray = 3 then
				set selection range to cell (item 3 of myArray)
			else
				set selection range to cell "A1"
			end if
		end tell
		
	end tell
end tell


on theSplit(theString, theDelimiter)
	-- save delimiters to restore old settings
	set oldDelimiters to AppleScript's text item delimiters
	-- set delimiters to delimiter to be used
	set AppleScript's text item delimiters to theDelimiter
	-- create the array
	set theArray to every text item of theString
	-- restore the old setting
	set AppleScript's text item delimiters to oldDelimiters
	-- return the result
	return theArray
end theSplit

May 8, 2021 1:44 AM in response to pheonix2610

Another approach is to use the Find function


Use an empty cell on each table to contain a distinct piece of text. Distinct, in this case meaning "existing in this document only in that one cell."


To get (immediately) to any table in the document, press command-F to open Find and Replace, then type in the 'code' for that table.


(If you have given every table a distinct name, that name,placed in a cell on the table, could become the table's 'find me code'.)


Regards,

Barry

How do I link a Table in Apple Numbers?

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