Function that returns name og curred sheet

  • Thread starter Thread starter hans
  • Start date Start date
H

hans

Does anyone know hot to make a function that returns the name of the curred
sheet as a string

I would like to have something like

="You are on sheet" & sheetname()

Greetings Hans
 
Hi
To get the current worksheet name try:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
 
Note that this requires that the workbook has been saved at least once
(rather than being a new workbook with a default name like Book1 as an
example).

--
Regards,
Tom Ogilvy

Frank Kabel said:
Hi
To get the current worksheet name try:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)

--
Regards
Frank Kabel
Frankfurt, Germany
Does anyone know hot to make a function that returns the name of the
curred sheet as a string

I would like to have something like

="You are on sheet" & sheetname()

Greetings Hans
 
Hans

Programming method.

Function SheetName(Optional ByVal rng As Range) As String
Application.Volatile
If rng Is Nothing Then Set rng = Application.Caller
SheetName = rng.Parent.Name
End Function

Gord Dibben Excel MVP
 
Thanks for the help.

Greeetings Hans


Gord Dibben said:
Hans

Programming method.

Function SheetName(Optional ByVal rng As Range) As String
Application.Volatile
If rng Is Nothing Then Set rng = Application.Caller
SheetName = rng.Parent.Name
End Function

Gord Dibben Excel MVP
 
Back
Top