How do I insert the filename of the worksheet into a cell?

G

Guest

I always use a filename for my worksheet that defines the worksheet itself.
Say a student class record for subject "CEPS 361 2nd sem 2005-06 Hydraulics"
would have that excel name with an extension of .xls, i.e. "CEPS 361 2nd sem
2005-06 Hydraulics.xls". Now I want this subject name to appear on the class
record to identify that this class record is for that subject, and what I
would like to happen is that its time I change the name to another subject
(as I only copy an existing worksheet and rename it to another name for
another subject) it would also appear on the class record the new name of the
subject without physically editing the cell. I don't want to use a header or
a footer for this and I still do not know anything about macros. Is this
possible without using a header or a footer or even a macro? If it is may I
know how? Thanks.
 
A

Ardus Petus

=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,SEARCH("]",CELL("filena
me"))-SEARCH("[",CELL("filename"))-1)

HTH
 
D

Dave Peterson

Just a couple of warnings to the OP:

#1. The workbook has to be saved for this formula to work.
#2. It's better to include a reference to a cell in a worksheet in that
workbook so that the formula evaluates correctly.

If you don't include that reference, then the formula will return the name of
the activeworkbook when excel recalculates--not the name of the workbook with
the formula.

Change each
Cell("Filename")
to
Cell("filename",a1)

(any cell is ok)

Ardus said:
=MID(CELL("filename"),SEARCH("[",CELL("filename"))+1,SEARCH("]",CELL("filena
me"))-SEARCH("[",CELL("filename"))-1)

HTH
--
AP

joeker said:
I always use a filename for my worksheet that defines the worksheet itself.
Say a student class record for subject "CEPS 361 2nd sem 2005-06 Hydraulics"
would have that excel name with an extension of .xls, i.e. "CEPS 361 2nd sem
2005-06 Hydraulics.xls". Now I want this subject name to appear on the class
record to identify that this class record is for that subject, and what I
would like to happen is that its time I change the name to another subject
(as I only copy an existing worksheet and rename it to another name for
another subject) it would also appear on the class record the new name of the
subject without physically editing the cell. I don't want to use a header or
a footer for this and I still do not know anything about macros. Is this
possible without using a header or a footer or even a macro? If it is may I
know how? Thanks.
 

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