Function that returns name og curred sheet

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
 
F

Frank Kabel

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

Tom Ogilvy

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
 
G

Gord Dibben

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
 
H

hans

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top