Get table name on worksheet using formulas without using VBA

sspatriots

Well-known Member
Joined
Nov 22, 2011
Messages
585
Office Version
  1. 365
Platform
  1. Windows
Happy New Year!

I have a worksheet that list all of the worksheet names in the workbook by tab order from left to right. Column A shows the actual Worksheet number and Column B returns the corresponding Worksheet name. Each worksheet has either one table on it or no table at all. I'm looking to find a way to list the corresponding Table names in column C if one does indeed exist on that corresponding Worksheet. The part below was accomplished using this link: 3 Quick Ways to Get a List of All Worksheet Names in an Excel Workbook

Any help on this would be very much appreciated. Thanks, SS

12024
22023
32022
42021
52020
62019
72018
82017
92016
102015
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I think the method you are using is probably
Excel Formula:
=REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")
which uses the old Excel 4.0 macro commands. Structured tables were introduced in Excel 2007, so there are no commands in the old macro language to address them.

I know of no way to get table names without using VBA.
 
Upvote 0
That's exactly what I used for a named range "ListSheets" formula. As for the table names I did manage to get something together that worked. Since cells A1 and B1 were empty in each of my worksheets that contained a table and the tables started at A1 (upper left corner), I just put "=A2" in cell "A1". Then I added the following formula to cell B1 on each worksheet that contained a table: "=MID(FORMULATEXT(A1),2,FIND("[",FORMULATEXT(A1))-2)". This put the table name in cell B1 on each worksheet with a table. On my tab that listed all of the worksheet names from left to right and their corresponding table names in column C, I entered a list of sequential numbers down column A, used "=INDEX(ListSheets,A1)" for my formula down column B (which references the named range that has the formula you mentioned in your response to my original post and then for column B, I used the formula "=INDIRECT(B1&"!$B$1")" copied all the way down to the last sequential number used in column A.

It ended up looking like the following:
12024Table4711
22023Table47
32022Table46
42021Table44
52020Table6
62019Table7
72018
0​
82017
0​
92016
0​
102015
0​
112014
0​
122013
0​
132012
0​
142011
0​
152010
0​
162009
0​
172008
0​


Maybe this will help someone else down the road. Thanks, SS
 
Upvote 0
I think I get what you are doing but I am confused about one thing.
cells A1 and B1 were empty in each of my worksheets that contained a table and the tables started at A1
How can a table start at A1 and also A1 be empty?

Also if I start a table in A2 and then put this formula in A1
Excel Formula:
=A2
I do not get the same result. However, if I type "=" into A1 then click on A2, I get this formula
Excel Formula:
=Table2[[#Headers],[a]]
Then if I put your formula in B1 it gives me the table name.

Here is a slightly more elegant formula for B1.
Excel Formula:
=MID(TEXTBEFORE(FORMULATEXT(A1),"["),2,99)

This is a creative solution if there is only one table per sheet and if all the tables are in the same place and if the same cell is available in every sheet for the needed formula. However, I did not know any of those things when I tried to solve your problem based on your initial post. Nicely done.
 
Upvote 0
As you are using 365 you could use this formula instead
Excel Formula:
=TOCOL(TEXTAFTER(GET.WORKBOOK(1)&T(NOW()),"]"))
and then in the sheet you can just use
Excel Formula:
=ListSheets
which will then spill down as far as needed.
 
Upvote 0
Solution
I think I get what you are doing but I am confused about one thing.

How can a table start at A1 and also A1 be empty?

Also if I start a table in A2 and then put this formula in A1
Excel Formula:
=A2
I do not get the same result. However, if I type "=" into A1 then click on A2, I get this formula
Excel Formula:
=Table2[[#Headers],[a]]
Then if I put your formula in B1 it gives me the table name.

Here is a slightly more elegant formula for B1.
Excel Formula:
=MID(TEXTBEFORE(FORMULATEXT(A1),"["),2,99)

This is a creative solution if there is only one table per sheet and if all the tables are in the same place and if the same cell is available in every sheet for the needed formula. However, I did not know any of those things when I tried to solve your problem based on your initial post. Nicely done.
My table started in cell A2.
 
Upvote 0
As you are using 365 you could use this formula instead
Excel Formula:
=TOCOL(TEXTAFTER(GET.WORKBOOK(1)&T(NOW()),"]"))
and then in the sheet you can just use
Excel Formula:
=ListSheets
which will then spill down as far as needed.
That's clever. It worked great. Thank you
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Glad we could help & thanks for the feedback.
I have another issue that has popped up with this. The column populates as it is supposed to when I open the file. When other users open this same file they get "#BLOCKED!" in the first cell where the formula below is entered? Any idea what could cause this?

Excel Formula:
=ListSheets
 
Upvote 0
Make sure that they have macros enabled.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top