Question

I have my tabs named as month-end dates, and I am constantly forgetting to update the date cell (which becomes important when I have to print). So I figured I would use the 'Filename' property, the Left/Right/Mid function, and the Date function to automatically set the date cell. This is what I came up with:

=DATE(RIGHT(RIGHT(CELL("filename"),8),4),LEFT(RIGHT(CELL("filename"),8),2),MID(RIGHT(CELL("filename"),8),3,2))

The internal "RIGHT" grabs the last 8 chars of the filename (the worksheet title), then the external substring functions portion it out so that it can be used as parameters for the "DATE" function. And this works fine. The problem comes when I try to copy this over from worksheet to worksheet.

First, I have made sure that my tabs are NOT grouped.

But still, whenever I calculate ONE of the cells containing the filename property, it updates ALL of the worksheets to have the date of the last sheet used to calculate.

I.E. I calculate the date cell in sheet "05312013" and it changes all months' date cell to "05/31/2013" instead of JUST that one sheet as intended.

What is happening and how do I fix it?

Was it helpful?

Solution

To make CELL function always refer to the worksheet in which the formula resides you need to use a cell reference in each CELL function (any cell reference, but A1 is the default option), i.e.

=DATE(RIGHT(CELL("filename",A1),4),LEFT(RIGHT(CELL("filename",A1),8),2),MID(RIGHT(CELL("filename",A1),8),3,2))

If you don't do that then it refers to the last worksheet changed - which clearly isn't what you want

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top