You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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

Is there a way look up sheet index or name?

I have a pages document where i have one sheet per month, and one database sheet in the last tab.


I would like to use the sheet index to look up the right row in my database tables, so that the sheet for January (with index 1) can look up data in row 1 in my tables.


So, i would like to refer to the index of my sheet or, less preferrably, the name, which means that i'd have to call them 0, 1 etc.


Right now, i have a hidden cell where i put the sheet index and it works, i'm just experimenting with trying to make it cleaner.

Posted on Jul 25, 2021 11:22 PM

Reply
Question marked as Top-ranking reply

Posted on Jul 27, 2021 7:14 AM

The formula that can tell you the sheet name is REFERENCE.NAME . It will give the full reference to a cell as text as in January::Table 1::A1. You can parse the string using the LEFT function to get just the sheet name. If your sheets are month names, you can use MONTH to turn the name into a number. As an example, I have a table named "Table 1" on a sheet named "January" and in cell B2 I have this formula to get me the month number:


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


You can use that number with the INDEX function to access your "database". I have a sheet named "Database" with a table named "Table 1" that has five columns (A:E) and one header row. Because of the one header row, January is in row 2. The formula I would use to access the data in column 1 for the month is:


=INDEX(Database::Table 1::$A:$E,$B2+1,1)


To access the next column you change the final 1 to a 2, and so on. You can use the COLUMN function to advance the number vs hardcoding 1,2,3 etc. into the formula. If my formula was in cell C2 (column #3) the formula would be


=INDEX(Database::Table 1::$A:$E,$B2+1,COLUMN()-2)


This formula can be filled to the right to get the data from the other columns of data.

Similar questions

9 replies
Question marked as Top-ranking reply

Jul 27, 2021 7:14 AM in response to Mathiasaf

The formula that can tell you the sheet name is REFERENCE.NAME . It will give the full reference to a cell as text as in January::Table 1::A1. You can parse the string using the LEFT function to get just the sheet name. If your sheets are month names, you can use MONTH to turn the name into a number. As an example, I have a table named "Table 1" on a sheet named "January" and in cell B2 I have this formula to get me the month number:


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


You can use that number with the INDEX function to access your "database". I have a sheet named "Database" with a table named "Table 1" that has five columns (A:E) and one header row. Because of the one header row, January is in row 2. The formula I would use to access the data in column 1 for the month is:


=INDEX(Database::Table 1::$A:$E,$B2+1,1)


To access the next column you change the final 1 to a 2, and so on. You can use the COLUMN function to advance the number vs hardcoding 1,2,3 etc. into the formula. If my formula was in cell C2 (column #3) the formula would be


=INDEX(Database::Table 1::$A:$E,$B2+1,COLUMN()-2)


This formula can be filled to the right to get the data from the other columns of data.

Jul 27, 2021 1:07 AM in response to Mathiasaf

Hi Mathiasaf,


No problem. I shall ask our hosts to move this discussion to the Numbers for Mac forum.

In the meantime, please reply with screen shots of a small part of your screen (shift command 4). Full screen shots (shift command 3) are often difficult to read.


To take a screen shot:


1. Remove or hide any personal details before taking the screen shot.

2. Hold down the shift and command keys, then type 4. The cursor will change to crosshairs.

3. Drag over the relevant part of your screen and then release the mouse/trackpad. You will hear a "camera shutter" sound. A screen shot will appear on your desktop. It will be named Screen Shot with a date & time.

4. In a reply to a message, click on the "Mountains" icon in the Toolbar below your reply: 

5. Navigate to your Desktop, click on a screen shot file, then click on Choose.


Regards,

Ian.


Jul 27, 2021 12:38 PM in response to Badunit

Hi BadUnit, thanks for responding. This was just what i was after!

(I had to change the commas in your LEFT-formula to semicolons to make it work though)


Huge thanks!


As a sidenote: It's a shame that there's no call for "getSheetName()" or something and instead you have to do rather cumbersome string parsing. I guess it's perhaps not a very common use case.


Is there a way look up sheet index or name?

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