PDA

View Full Version : UDF Function to refer to the Sheet Name



YasserKhalil
08-06-2010, 02:45 AM
Hi everybody
I have a UDF function which returns the sheet name
The problem is that when renaming the sheet it doesn't change until I click double in the cell which contains the function
Is there a way to update the result??


Function SheetName()
SheetName = ActiveSheet.Name
End Function

GTO
08-06-2010, 03:30 AM
Have you tried:


=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)

Bob Phillips
08-06-2010, 04:20 AM
Call it with

=SheetName()&TEXT(NOW(),"")

YasserKhalil
08-06-2010, 07:31 AM
Thanks Mr. Mark
Good formula
---
Mr. xld
A very good trick and it solves the problem
But I hope to find a better solution as I encountered such problem in another UDF function

mbarron
08-06-2010, 08:08 AM
You can add Application.Volatile True to your code as well.
Function SheetName()
Application.Volatile True
SheetName = ActiveSheet.Name
End Function

YasserKhalil
08-06-2010, 08:13 AM
Mr. mbarron
That's the point ..
Excellent solution
But please could you explain the first line of the code
Application.Volatile True

GTO
08-06-2010, 08:28 AM
Call it with

=SheetName()&TEXT(NOW(),"")

That's neat!