Inserting worksheet name into a cell


Posted by Janet on October 12, 1999 3:04 AM

How can I insert the name of a worksheet into a cell, so that if the name is changed, the cell automatically updates?

Posted by Chris on October 12, 1999 5:32 AM

Janet,

You can do this with a custom function. Copy the following function to a module sheet within the workbook:

Function SheetName()
SheetName = ActiveSheet.Name
End Function

You then can type the following formula in any cell on the sheet.

=SheetName()

This recalcs like any other formula would.

HTH
Chris

Posted by Rudolf on April 12, 0100 7:02 AM

Gary,

There is indeed a simple way to get the filename into a cell:

Posted by Rudolf on April 12, 0100 7:05 AM

the formula is: =cell("filename";a1)

excuse for sending it in 2 parts

Posted by brad gardiner on May 30, 0100 9:00 AM

I'm trying to put the worksheet name in a cell to be used in a formula and the code above will not work for me. I'm using Excel 2000. Any ideas?

Thanks,
Brad

Posted by Gary Ford on February 10, 0100 10:39 AM

Chris

I am using 97 and whilst the function you specify works OK first time I find that it does not introduce changes automatically. Is there an alternative of making this function a global one (or something similar) rather than linking it to a specific sheet?

Regards

Gary



Posted by mads on June 21, 0100 2:25 PM

Try :-
=CELL("filename")
mads

PS. Rather than add messages to very old questions, you will be more likely to receive replies if you add a new question. I just happened to notice your message when looking for something else.