Sheet Name

J

John Viall

I am trying to make a function that collects the name of a
sheet, and automatically fill in a cell on that sheet with
the name.

I'm trying something like:

Public Function Name() As String
On Error GoTo Skip
Back:
For x = 1 To 35
Name = Sheets(Sheet & x).Name
Next x
Skip:
x = x + 1
GoTo Back
End Function

Any help would be appreciated.

Thanks,
John
 
T

Tom Ogilvy

I assume this will be used in a worksheet

Public Function MyName()
Application.Volatile
MyName = Application.Caller.Parent.Name
End Function

It will only update when a calculation is performed.
 
V

Vasant Nanavati

Hi John:

Try:

Public Function SheetName() As String
SheetName = Application.Caller.Parent.Name
End Function

Regards,

Vasant.
 

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