7

Scenario:

  • Have a spreadsheet (Numbers.app v3.6.2/El Capitan)
  • it contains multiple Sheets (every sheet contains multiple tables, but this doesn't matter)
  • Every sheet is renamed to some defined name, for example the Sheet 2 is renamed to Feb (month name abbrev).
  • need get into the cell content the current sheet name e.g. something like the hypothetical function =GETSHEETNAME(), so in the sheet named as Feb, want get to some cell the string Feb.

My reading of the Numbers.app function reference failed and I doesn't find any function for such operation. Is it possible somehow?

EDIT

At the https://iworkautomation.com/numbers/sheet.html I found some applescript, but haven't idea how to use it... :(

clt60
  • 8,459
  • Note that depending on regional settings in your computer - separators may be twisted so instead of decimal being . it may be , and then you get function parameter separator to be ; So technically there are many solutions, and either may or may not work. Luckily - there are both separator options in the answers. – tishma Jan 31 '24 at 13:10

2 Answers2

3

REGEX.EXTRACT(REFERENCE.NAME(;2);"[^:]+";;) returns the sheet name of the current sheet

zorro
  • 46
  • Welcome to [apple.se]! Your answer has been flagged as low-quality; it may work, but perhaps you can add references to the documentation? – Glorfindel Jan 09 '21 at 19:06
  • Would be nice, unfortunately it says for me: "The formula contains a syntax error" and also I can't find any function called REGEX. Using Numbers.app ver 6.1. – clt60 Jan 12 '21 at 12:30
  • Just found, the REGEX is probably introduced in the version 10.1, so unusable for me (I'm still using High Sierra (10.13.6) and the 10.1 Numbers requires at least 10.15). Thanks anyway - couldn't accept it, but upvoting it as an possible solution. – clt60 Jan 12 '21 at 12:39
  • Sorry, wasn't aware of that (I'm using Numbers version 10.3.5). If your version already supports the function REFERENCE.NAME you could use this variant: LEFT(REFERENCE.NAME(;2;);FIND(":";REFERENCE.NAME(;2;))−1). Ugly, but works without REGEX. – zorro Jan 12 '21 at 19:27
3

I'm not sure if it's changed for v13 (what I'm using) in macOS Monterey but to do this now I have to replace all zorro's uses of ";" with ",":

LEFT(REFERENCE.NAME(,2,),FIND(":",REFERENCE.NAME(,2,))−1)

If I don't then it fails with a syntax warning.

Thanks for the tip and for getting me 99.99% there, zorro!