Joinersfolly
04-26-2016, 07:46 AM
In my code I used the bolded line below which seemed to work fine, however I found to my horror that each day I opened my workbook
all the dates changed to reflect whatever the date is today not what date 'Today' was the day i entered the code ie.
if on the 16/04/2016 i used "=Today()-" & Varname
16/04/2016-3 I got 13/04/2016 which is what i wanted.
However when i opened the sheet again on 20/04/2016 the cell result had changed to 20/04/2016-3 =17/04/2016
Once the date has been entered I do not want it to change again.
Will the change from the underlined code to the row below it work?
Regards
Dim LastRow As Long'Dim Varname As Integer
Dim Unchanging As Variant
Unchanging = Date
'MsgBox Unchanging
Dim Varname As Variant
If Target.Address = "$D$1" Then
Varname = Range("D1")
'Range("A" & LastRow).Formula = "=Today()-" & Varname
Range("A" & LastRow).Value = Unchanging - Varname
all the dates changed to reflect whatever the date is today not what date 'Today' was the day i entered the code ie.
if on the 16/04/2016 i used "=Today()-" & Varname
16/04/2016-3 I got 13/04/2016 which is what i wanted.
However when i opened the sheet again on 20/04/2016 the cell result had changed to 20/04/2016-3 =17/04/2016
Once the date has been entered I do not want it to change again.
Will the change from the underlined code to the row below it work?
Regards
Dim LastRow As Long'Dim Varname As Integer
Dim Unchanging As Variant
Unchanging = Date
'MsgBox Unchanging
Dim Varname As Variant
If Target.Address = "$D$1" Then
Varname = Range("D1")
'Range("A" & LastRow).Formula = "=Today()-" & Varname
Range("A" & LastRow).Value = Unchanging - Varname