ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Store calculated date as a literal value (https://www.excelbanter.com/excel-programming/369504-store-calculated-date-literal-value.html)

Mike Hann

Store calculated date as a literal value
 
I want to calculate a date and store it as a literal in a cell so that it is
not updated each time the worksheet is updated.

I want the previous Month and current Year from when the worksheet is
created to be stored in a cell so that I can use it in charts. I don't what
it to be updated if the worksheet is opened up at a future date.

Alan.M

Store calculated date as a literal value
 
I'm guessing that your dates are calculated by a Marco, and you want the
macro to run only if it hasn't before.... so you could
test that the target cells are empty and if they are
write out todays month - 1 month
write out todays year
msg box to says it's happened
(else "do nothing" is implied)

Sub mydate()
If Cells(3, 2) = "" Then
Cells(3, 2) = Month(Date) - 1
Cells(3, 3) = Year(Date)
MsgBox "date done"
End If
End Sub
hope that helps,

"Mike Hann" wrote:

I want to calculate a date and store it as a literal in a cell so that it is
not updated each time the worksheet is updated.

I want the previous Month and current Year from when the worksheet is
created to be stored in a cell so that I can use it in charts. I don't what
it to be updated if the worksheet is opened up at a future date.



All times are GMT +1. The time now is 04:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com