+ Reply to Thread
Results 1 to 7 of 7

CELL("filename") returns the same sheet name on three different sheets

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,993

    CELL("filename") returns the same sheet name on three different sheets

    See attached. The following formula is found in the same cell in each of three worksheets:

    =CELL("filename")

    When I entered it on Sheet3, it showed that the sheet name was Sheet3, but when I returned back to Sheet1, it also said Sheet3. When I hit F9, it showed Sheet1, but then so did the other two sheets!

    I discovered this odd behavior attempting to help in another thread.

    I have done a bit of web searching but find no mention of this, only a description of how the CELL function works.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723

    Re: CELL("filename") returns the same sheet name on three different sheets

    If you omit a cell reference the formula will refer to the sheet of the last cell that you changed. Put in a cell reference (any cell) like this

    =CELL("filename",A1)

    ....and it will always refer to the sheet in which the formula resides

    Excel help for CELL says

    "reference Optional. The cell that you want information about. If omitted, the information specified in the info_type argument is returned for the last cell that was changed. If the reference argument is a range of cells, the CELL function returns the information for only the upper left cell of the range."
    Last edited by daddylonglegs; 01-21-2013 at 06:19 PM.
    Audere est facere

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CELL("filename") returns the same sheet name on three different sheets

    You have to include a cell reference that will "anchor" the formula to the specific sheet:

    =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,31)

    The cell reference can be to any cell. The formula is referencing cell A1 but it doesn't need to be entered in cell A1.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,993

    Re: CELL("filename") returns the same sheet name on three different sheets

    This was solved by Tony Valko in the other thread. The problem does not occur if you include the optional cell reference argument:

    =CELL("filename",A1)

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,993

    Re: CELL("filename") returns the same sheet name on three different sheets

    That's funny, I previewed this before I added my post and didn't see the above two posts. Thanks to both.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CELL("filename") returns the same sheet name on three different sheets

    Quote Originally Posted by daddylonglegs View Post
    Excel help for CELL says

    "reference Optional. The cell that you want information about. If omitted, the information specified in the info_type argument is returned for the last cell that was changed. If the reference argument is a range of cells, the CELL function returns the information for only the upper left cell of the range."
    In other words...

    If a cell reference is omitted, the formula will return the sheet name of the sheet that was active when the last calculation took place.

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723

    Re: CELL("filename") returns the same sheet name on three different sheets

    Agree entirely Biff - of course the help text is generic because it refers to any info_type, e.g. if you use

    =CELL("format")

    then, similarly, you get the format of a variable cell rather than a fixed one

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1