I want to display the table name in a cell. This is what I have come up with, as I needed a solution which doesn’t use arrays or macros.

Is there a way to condense these formulas into a single cell? I’d like to make it so I have only one cell, which I can paste wherever I like, which dynamically displays the name of this table.

enter image description here

Column M is just FORMULATEXT of the column on the right, for illustration purposes.

The idea behind this is that if I cut and paste the table, including the cells immediately to its left, to somewhere else in the spreadsheet, it will still work correctly and display the name of the table. The structured reference in the cell N24 ensures that it will still work, even if I insert something else in between the table and current column N.

  1. Cell n25 returns the name of the header of an arbitrary column in the table. The advantage is that this will update automatically when the name of the table or column name changes, and doesn’t depend on the table being in a particular location.
  2. Cell n24 grabs part of the formulatext in n25. Specifically, it starts searching from the second character (i.e., after the = in the formula) until it finds the [[ which marks the end of the table name and the start of the column name (we only want the table name). This works on my Excel 2016, but unfortunately won't work on earlier of Excel, versions, which is a pain
  3. Cell n23 finds and removes the square brackets from what’s returned in n24.
  4. Cell n22 removes the underscores and replaces them with spaces. Not strictly necessary, but it looks tidier.

The problem with this way of doing it is that the upper three cells have to be placed above the current n25 for it to work. They take up space and look messy. I’ve got around it by just setting the text colour of the cells to white, except the top one.

Is there a better way to do this, while not using macros or arrays, bonus points for a solution which can be used in Excel 2010? Or will this question just be the exhibit they use to mark my slide into insanity?


Without a macro or vba UDF, there may not be a single cell solution. Here is the OP solution condensed into two cells. Perhaps cell N25 could use ;;;"" custom formatting, to format the cell text as blank (or use the, font color same as background color, trick).

N25=Scans_per_day_by_site[[#Headers],[Location]] Formula=PROPER(SUBSTITUTE(MID(FORMULATEXT(N25),2,FIND("[",FORMULATEXT(N25))-2),"_"," "))

Besides adding Title Capitalization using PROPER, the only difference between this answer and the OP is the calculation of the MID characters to return.

  • First, FIND returns the location where the text is first found in its second argument: N25 (not MID(2,N25,...).
  • With MID, returning this number of characters from the beginning of N25 would include the found character.
  • To exclude the found character, subtract 1 from the number of characters.
  • Since the start of MID is 2, a character is removed from the beginning shifting the returned characters right by one.
  • Again, this is one more character than needed.
  • Subtract another 1 for a total of - 2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.