Display Worksheet in Excel File

G

Guest

I want to Display the worksheet name on the Excel Spreadsheet itself.

ie. On Worksheet1, Cell A1 = Worksheet1

How do I do this without having C:\Desktop\Book1.xls\Worksheet1??
 
F

Fredrik Wahlgren

Rowf said:
I want to Display the worksheet name on the Excel Spreadsheet itself.

ie. On Worksheet1, Cell A1 = Worksheet1

How do I do this without having C:\Desktop\Book1.xls\Worksheet1??

You have to make a User Defined Function. Start the Visual Basic Editor,
insert a new module and enter

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

Now, if you enter =wks() in a cell in any worksheet, wks will return the
name of that worksheet.

/Fredrik
 
G

Gord Dibben

Rowf

Enter in any cell on a sheet.

=MID(CELL("FILENAME",A1),FIND("]",CELL("FILENAME",A1))+1,255)

File must have been saved at least once.


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