Sheet names code

J

Jonah

Is there away to get the name of a worksheet onto the worksheet itself
in a cell?

Jonah
 
T

T Kirtley

A formula like:

=CELL("filename")

will return the filename, including the full directory path.

If you only want the filename, excluding the directory path try something
like

=MID(CELL("filename"),LEN(INFO("directory"))+1,99)

HTH,

TK
 
K

Ken Johnson

Jonah said:
Is there away to get the name of a worksheet onto the worksheet itself
in a cell?

Jonah

=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))

Returns an empty string until workbook is saved.

Ken Johnson
 
D

Dave Peterson

it's best to include a reference to that worksheet that you want:

=cell("filename",a1)
(any cell will do)

If you don't include a cell reference, then this formula will evaluate to the
name of the sheet that's active when excel calculates. It may not even be in
the same workbook!
 
C

Chip Pearson

You should add a cell reference (it doesn't matter what cell) to the CELL
functions. E.g.,

CELL("filename",A1)

Without the reference, the value returned by CELL is the workbook/worksheet
that is active when the cell containing the formula is calculated. If a
sheet other than the sheet containing the formula is active, you'll get the
wrong result.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)


Ken Johnson said:
Is there away to get the name of a worksheet onto the worksheet itself
in a cell?

Jonah

=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))

Returns an empty string until workbook is saved.

Ken Johnson
 
K

Ken Johnson

Chip said:
You should add a cell reference (it doesn't matter what cell) to the CELL
functions. E.g.,

CELL("filename",A1)

Without the reference, the value returned by CELL is the workbook/worksheet
that is active when the cell containing the formula is calculated. If a
sheet other than the sheet containing the formula is active, you'll get the
wrong result.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)

Thanks Chip

Ken Johnson
 
Top