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.
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.
- 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.
- 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
- Cell n23 finds and removes the square brackets from what’s returned in n24.
- 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?