You might be in the process of creating a product model in which there are 25 different products, and each product occupies a sheet within the model. Let's say that you name each sheet for each different product, and have a title on each sheet that also matches the name of the product. If you decide to change the nomenclature, you may be making 25 changes twice over (or even more than that, if you are using the product name in multiple cells on each sheet).
How do we link to sheet names? |
- Start with a formula that will return a string of text containing the sheet name. Assume you are on "Sheet1." You can go to cell B3 and enter: =+CELL("filename",$B$3), which returns "C:\Folder\[filename.xlsx]Sheet1"
- Having the filepath and sheet name, you can create a function that returns only the part of this string of text that follows the "]," which would be "Sheet1"
- One function that will work to return only the text following "]" is the RIGHT function: =+RIGHT(CELL("filename",$B$3),a) where a is the number of characters following "]"
- Obviously, if all of your sheet names are 6 characters in length, you can just use the function from step 3 with a = 6,. But a truly dynamic function will require solving for "a" in all cases. So first, let's assume a = b - c, where b is the total length of the filename and c is the total number of characters through "]"
- To find "b," use =+LEN(CELL("filename",$B$3)), which tells you that the filename is 31 characters in length
- To find "c," use =+SEARCH("]",CELL("filename",$B$3),1), which tells you that "]" occupies the 25th position starting from the left in "C:\Folder\[filename.xlsx]Sheet1"
- Using a = b - c, we have a = 31 - 26 = 5. In formulaic terms, a = LEN(CELL("filename",$B$3))-SEARCH("]",CELL("filename",$B$3),1)
- Thus, using the formulae from steps 3 and 7, the sheet name is =+RIGHT(CELL("filename",$B$3),LEN(CELL("filename",$B$3))-SEARCH("]",CELL("filename",$B$3),1))
-F-One