andreascostas
Board Regular
- Joined
- Jan 11, 2011
- Messages
- 150
Is there a way to insert the name on the tab of an excel sheet into cell A1
without having to type it every time?
without having to type it every time?
Yes you can... at least I can keep the number 31
=IFERROR(REPLACE(CELL("filename",A1),1,FIND("]",CELL("filename",A1)),""),SUBSTITUTE(RIGHT(SUBSTITUTE(SUBSTITUTE(LEFT(SUBSTITUTE(
CELL("filename",A1),".",REPT("?",5)),LEN(SUBSTITUTE(CELL("filename",A1),".",REPT("?",5)))-5),"?",""),"\",REPT("?",31)),31),"?",""))
Function sheetname()
sheetname = ThisWorkbook.ActiveSheet.Name
End Function
What will cause the function to update if the sheet name is changed?How about an UDF
Code:Function sheetname() sheetname = ThisWorkbook.ActiveSheet.Name End Function
Same questionthen like this:
Code:Function sheetname(r As Range) sheetname = ThisWorkbook.ActiveSheet.Name End Function
Use:
=sheetname(A2)
Here I have changed the sheet name from "def" to "ghj"What will cause the function to update if the sheet name is changed?
Same question
Function sheetname(r As Range)
Dim l As Workbook, s As Worksheet
Set l = ThisWorkbook
Set s = l.ActiveSheet
sheetname = s.Name
End Function
Function sheet_name(r As Range)
Application.Volatile
sheet_name = r.Parent.Name
End Function
What will cause the function to update if the sheet name is changed?
.. and in any case, if it does update while the sheet it is on is not the active one it will return the incorrect name.