Sheet Name

A formula to put the sheet’s name into a cell


The CELL() function with the “filename” argument will return the full path of the workbook plus the sheet name. The workbook will be enclosed in brackets []. This formula finds the right bracket (]) and returns everything after that.

Note that if the workbook has not been saved, there is no path, and this formula returns a #Value error.

Posted in Uncategorized

25 thoughts on “Sheet Name

  1. As an alternative, this has two fewer function calls:


    255 is just a big number. Could be anything >=31.

  2. Can I use this formula somehow to grab the sheet name of a different excel file and place it in a cell of the current excel file?

  3. You could use something like this to do that for you.


    The cell references for the CELL() function have been changed for cells on the sheet that you are interested in in another workbook. This only works if the other workbook is open though otherwise it returns the #N/A error.

  4. OH,thanks john.
    I dont think that will work for me. I have an autocad created excel file. AutoCAD assigns random name to the excel sheets, but the file name is always the same. I need to grab the random name and put it in a different excel file. I have not been able to find anyone who can do it so far.

  5. I want to enter “sheet2? into A1 of sheet1. Then I want to sum A1:A5 of sheet2.

    the formula would be =SUM(sheet2!A1:A5)

    I would like to pull the sheet name from A1 of sheet1. The reason for this is because I have data relating to all 10 provinces in one workbook and I want to write a formula that will pull the province name from a cell in Sheet11 to correspond to the sheet name that I want to sum up.

    I would like to write a formula like this

    where A1 will return sheet2

    I hope this makes sense.

    Is this possible.

  6. Matt,

    Using the INDIRECT function like this:


  7. I want to use the conditional sum function on sheet 2, but refer to a data range on sheet 1. I have successfully used the conditional sum wizard to enter three conditions, placing the formula on sheet 1. However, I need to put these totals on sheet 2, separate from the data on sheet 1.


    How do I add a reference to Sheet 1 in this formula?

  8. I have answered my own question. When asked for the data range, I clicked to Sheet 1 and selected the data range. I actually had tried manually adding the reference to “Sheet1!” but it did not work until I went back into the Conditional Sum Wizard and highlighted the cell range.

    Why am I unable to edit my formula after using Conditional Sum Wizard? I tried the above edit and it didn’t work. Then I tried to change the reference to one column (change from C1:C10 to D1:D10), but when I do that it is invalid and I must start all over using the Wizard.

    I am using Excel 2000. Do the newer versions resolve that problem?

  9. Hi Robin –

    The conditional sum wizard produces an array formula. Notice that it has {curly braces} around it in the formula bar? When you create or edit an array formula, you have to hole CTRL+SHIFT while pressing Enter, in order to produce a valid array formula.

    – Jon

  10. I am working in the same array formulas and have another question. I have a Conditional Sum formula and need one of my conditions to say this: “If C2:C17 is not blank (it will contain a number), add the numbers.” What I need to know is how to express the condition “not blank.”

    Thanks very much!

  11. re “put sheet name into a cell” (Excel XP)

    ie. =RIGHT(CELL(“filename”,A1),LEN(CELL(“filename”,A1))-FIND(“]”,CELL(“filename”,A1))) and similar.

    The above does not appear to work well when there are multiple sheets in a workbook. eg. I use the formula to display the sheetname on about 12 sheets. Unfortunately, at any one point in time, all the same sheetname is displayed on all sheets. The formula appears to display the sheetname of the sheet with the most recently “recalculated” cell value.

    Simply switching from one sheet the next does not change the sheetname displayed. The displayed name only changes to the currently open sheet if:

    + Press F9 to recalculate a value (/values) on the ‘active’ worksheet
    + or say enter data or a formula and press enter; ie. this appears to make the “open” sheet the “active” sheet.

  12. David,

    Are you sure you have a cell reference after “filename”? eg. CELL(“filename”) vs. CELL(“filename”,A1) — with the cell anchor you shouldn’t have to recalculate in order to see it.


  13. This will work in a cell to get the sheetname of a refference (and does not require the file to be saved) Note however you cannot use it on the sheet you are getting the name of… Excel automatically gives local address and then doesn’t have the sheetname.. :P

    =MID((CELL(“Address”,’Sheet You Want The Name of’!$A$1)),(FIND(“]”,CELL(“Address”,Sheet You Want The Name of’!$A$1),1)+1),(FIND(“!”,CELL(“Address”,’Sheet You Want The Name of’!$A$1),2)-1)-(FIND(“]”,CELL(“Address”,’Sheet You Want The Name of!$A$1),1)+1))

    Still Requires Recalculation.

    Hope this helps someone…

  14. This is all facinating, but I was looking for something the other way round.

    How do I set a worksheet name to the value of a Cell.

    ie I have a cell H1 containing
    “January 2008?
    and I want sheet1 to be labelled this programmatically
    which would save me manually changing all 7 worksheets every month

  15. excel 2002

    I want to use the name of the ACTIVEworksheet into the chart label or textbook.
    I already can get the worksheet name into a cell.

    NOTE. I name each tab by date and then want this date on the chart which I print out.

  16. THANKS !!!

    adding in the reference to A1 (ie CELL(“filename”,A1) rather than simply CELL(“filename”) did the trick for me !! :-D

  17. I am using formula for Filename in one cell. When another file is opened, the filename of this new file gets updated in the earlier file. For example File named “123.xlsx” is open, the cell A1 shows “123?. When the file named “xyz.xlsx” is opened, cell A1 in file 123.xlsx shows “xyz”
    How to fix this.
    Thanks in advance

Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.