Excel - Insert Worksheet Name into Cell
Solved/Closed
Hello,
Do you have the trick to insert the name of a worksheet tab in an Excel cell?
Thank you allConfiguration: Windows XP
Internet Explorer 6.0
Do you have the trick to insert the name of a worksheet tab in an Excel cell?
Thank you allConfiguration: Windows XP
Internet Explorer 6.0
34 answers
-
tétoThe correct formula is:
=RIGHT(CELL("filename",A1), LEN(CELL("filename",A1))-FIND("]", CELL("filename",A1)))
A + -
gbinforme Contributorhello
Without using a macro, it is entirely possible with this formula:for the sheet name =MID(CELL("filename");FIND("]";CELL("filename"))+1;20) or of course you can replace the length 20 by calculating the correct length but is it worth the effort? =MID(CELL("filename");FIND("]";CELL("filename"))+1;LEN(CELL("filename"))-FIND("]";CELL("filename"))) for the workbook name =MID(CELL("filename");FIND("[";CELL("filename"))+1;FIND("]";CELL("filename"))-FIND("[";CELL("filename"))-1) and the full path =CELL("filename")
ps: the display is incorrect because instead of &.q.u.o.t.; it should be "
--
always zen-
gillou58I am interested in the formula:
for the name of the workbook
=MID(CELL("filename"),FIND("[",CELL("filename"))+1,FIND("]",CELL("filename"))-FIND("[",CELL("filename"))-1)
But do you have a trick to remove the extension (.xls for example) that appears along with the filename?
Thank you in advance. -
gbinforme Contributor@gillou58Hello
You didn't search much because it's very simple:=MID(CELL("filename");FIND("[";CELL("filename"))+1;FIND("." ;CELL("filename"))-FIND("[";CELL("filename"))-1)
I'll let you figure out the difference...
--
Always zen -
-
GalileoIntuitively, I would tell you to put this formula in each tab on a hidden row, then in the tab where you want to see everything, you create a table containing references to the contents of your hidden cells in each tab...
But I'm anything but an Excel expert, more of a tinkerer, so there’s probably a better way! :)
Good luck,
Galileo -
-
-
bibidelHello Seb,
Here is the formula that works in a cell, it seems to correspond to your "happiness":
=MID(CELL("filename";A1);FIND("]";CELL("filename";A1))+1;20)
Best,
Bibidel -
mapaHello,
For the formula to work in a workbook with multiple tabs, you need to reference a cell from the sheet
=MID(CELL("filename",B1),FIND("]",CELL("filename",B1))+1,LEN(CELL("filename",B1))-FIND("]",CELL("filename",B1))) -
eriiic ContributorYou did exactly what you had to do, adding the optional cell reference, and that way you point to a cell in your sheet (instead of the active sheet...).
You can leave A1 in each formula (no link between the 2 of A2 and the 2 of sheet2) and therefore no increment needed, it's the same formula on all sheets.
And also add it to the first CELL(...;A1) to make it look cleaner.
eric -
eriiic ContributorHello,
Overall in agreement with dandan, and to have the active tab instead of sheet 1, you would need:
Cells(1, 1) = ActiveSheet.Name
and to get all the names, you can do a loop:
Sub name()
For Each sh In Sheets
i = i + 1
Cells(i, 1) = sh.Name
Next sh
End Sub
Otherwise, it is possible with a formula as long as you are in another sheet:
for example, in sheet2 enter:
=CELL("address";Sheet1!A2) => [Workbook1]Sheet1!$A$2
You just need to process the string to extract its name.
eric -
Oughdir hrouHello
this works well, it's quite possible with this formula that gives
the name of the tab
=MID(CELL("filename");FIND("]";CELL("filename"))+1;20)
or of course it's possible to replace the length 20 by calculating the correct length, but is the game worth the candle?
as follows;
=MID(CELL("filename");FIND("]";CELL("filename"))+1;LEN(CELL("filename"))-FIND("]";CELL("filename")))
and the full path
=CELL("filename -
eriiic ContributorGood evening,
Response to post 54.
To list all the sheet names, the workbook must first be saved, then:
" insert / name / define... "
'name in the workbook :' name_sheets
'Refers to :' =RAND()*0&TRANSPOSE(READ.BOOK(1))
Confirm
On line 1 of a sheet enter:
=MID(INDEX(name_sheets;ROW());SEARCH("]";INDEX(name_sheets;ROW()))+1;30)
to be copied down.
The #REF! from non-existent sheets can be eliminated with an additional test if needed (but this makes the formula heavier)
eric -
gbinforme ContributorHello
They work well but there is a display error on the site: check the PS
You need to replace "&.q.u.o.t.;" (the intercalated dots for display) with the quote simply.
I try again=MID(CELL("filename");FIND("[";CELL("filename"))+1;FIND("]";CELL("filename"))-FIND("[";CELL("filename"))-1)
PS: still not good... it goes over two lines and the two need to be grouped in the same cell
--
always zen -
nénéHello
Here is a small custom VBA function
Function SheetName() As String
Application.Volatile
SheetName = Application.Caller.Parent.Name
End Function -
bibidelThank you again to Eric and gbinforme
Here’s how I solved my issue temporarily, but I'm looking for a better solution:
It’s not great, but I don’t know how to increment (without macros) the sheet number in the workbook, so for each cell in each sheet, I modify the formula by changing (“filename”,A1) for sheet 1 (“filename”,A2) for the second, and so on...
The key is not to move the sheets.....
=MID(CELL("filename");FIND("]";CELL("filename";A1))+1;20) for sheet 1
=MID(CELL("filename");FIND("]";CELL("filename";A2))+1;20) for sheet 2
and so on...
See you soon
Bibidel -
bibidelThe formula to enter in the destination cell is as follows.
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,20)
20 corresponds to the maximum number of characters for the sheet name, and you can give it any value you want.
Bididel -
eriiic ContributorGood evening,
I can play too?
=MID(CELL("filename";A1);FIND("]";CELL("filename";A1))+1;20)
So weirdly this formula is exactly the same as yours bibidel, but if I copy/paste yours I also get an error (??)
I keep looking and I can't see the difference. Well, a tiny one in length as if a character was slightly wider...
So I pasted it as code. If there are still problems, I advise SebastienC44 to re-enter in Excel what is found between the ""..." including the "" even for ""[". A priori that's where it's bugging.
Weird, weird...
eric-
-
eriiic Contributor@bibidelhappy? Ahhh, it's a little bibi...
It's true that it's really a question full of twists and turns.
It works, it doesn't work, it works, it doesn't work
By the way, are you marking it as resolved or are we waiting for the next twist? ;-) -
gilouHello
while checking the forum resolutions (to try to improve myself) I attempted to answer
bibbel's question; it works for me with this:
Private Sub Worksheet_Activate()
[a1] = ActiveSheet.Name
End Sub
can you tell me if this solution answers bibbel's post no. 1 and if it is incongruous compared to the provided solutions
thanks and see you later
-
-
eriiic ContributorYes, surely a setting somewhere (Word?) that converts.
-
Binif=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,20)
This formula does not work in Microsoft Office 2007,
This one does...
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,20) -
bibidelTHANK YOU Ériiiiiiiiic! Life seems so simple afterwards!
-
SebastienC44Hello,
I went through your discussion thinking I had found my happiness:
I'm looking for a function that will allow me to display the name of the tab of this sheet in any cell of my sheet.
I copied the given formula but it doesn't work. Did I understand the purpose of your formula correctly? If so, why doesn't it work? If not, is it possible to do what I want?
Thank you very much,
Seb-
bibidelGood evening Seb,
The formula to type in the destination cell is as follows and it should match your "happiness"
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,20)
20 corresponds to the maximum number of characters for the sheet name, you can give it any value you want.
Best regards,
Bibidel -
-
c035145@PascalI confirm the remark made by bibidel that it doesn't work when pasting this kind of formula in multiple tabs of the same workbook.
Specifically, I want to see, for example, the name of the tab in cell A1 of each tab.
If I paste the formula =RIGHT(...) or the formula =MID(...) in each of the tabs, the same value will display everywhere, namely the name of the tab from which I activated the F9 recalculation key.
This formula does not therefore meet the need in the configuration I described. -
bibidel@c035145You must not copy-paste the formula; you need to enter it in each destination cell of each tab.
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,20)
And, normally, it works.
See you+ -
eriiic Contributor@bibidelHi bibidel,
it's been a while... :-)
And I don't know what's going on with you but you always have in the formula 2 simple quotes ' instead of a double quote "
=MID(CELL("filename";A1);FIND("]";CELL("filename";A1))+1;20)
Written this way, we should be able to copy-paste it
Happy New Year
eric
-
-
bibidelThe formula is as follows to type in the destination cell
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,20)
20 corresponds to the max number of characters for the sheet name, and we can give it any value we want.
Bibidel -
bibidelAlright Eriiic! pssssssss I've been found out
Catch you later! -
SebastienC44Hello and thank you for your numerous responses. I copied the formula into a cell on Sheet1, but it doesn't work (#VALUE!). I then read that I needed to copy everything between """", but still nothing?
Is there a trick I'm missing?
--
Seb -
- 1
- 2
Next