If Cell Contents =today() then....
You seem to have made your sub unnecessarily complicated.
This sub will compare the date in cell A1 with the current date and if they
don't match it will enter the current date and time in cell f2.
Sub hats()
Range("a1").Select
If DatePart("y", ActiveCell.Value) < DatePart("y", Now()) Then
Range("F2").Select
Selection.Value = Now()
End If
End Sub
HTH
Andy W
"nospaminlich" wrote:
I'm trying to write a macro where if the date in cell A1 is the same as
today's date then the macro ends but if the cell is blank or has any other
date then it puts today's date in cell F2
The code is below but it isn't recognising where the date in A1 is the same
as today's - it continues to put today's date in F2.
I'm not sure what I've done wrong but I've tried a number of variations on a
theme without success so I'm stuck and would really appreciate some help.
Thanks a lot
-------------
Sub hats()
Range("a1").Select
If ActiveCell.Value = "=today()" Then
End
ElseIf ActiveCell.Value < "=today()" Then
Range("F2").Select
ActiveCell.FormulaR1C1 = "=today()"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If
End Sub
|