How to program Excel worksheet when a value is entered in a worksheet, the cell to the right side is filled with the recorded today's date? The date value will saved and should not be changed as =TODAY() by daily.
Using the same mehtod as Rob but slightly different
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
Target.Offset(0, 1).Value = Format(Date, "dd/mm/yy"
Application.EnableEvents = True
End Sub
Rob - your code will cause an error as without enableevents = false, the code will loop until it gets to column IV Rgds
~Geoff~
cheers Rob - I don't test all code code either- just don't have the time - I think Top of the stars for this forum says a lot for you though - think we'll let this one slip ;-) Rgds
~Geoff~
A slight modification to Geoff's code will take care of that:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if target.column=1 then
Application.EnableEvents = False
Target.Offset(0, 7).Value = Format(Date, "dd/mm/yy"
Application.EnableEvents = True
end if
End Sub
There is a small note: when hit delete key in a cell of column A, the date also entered/update in column H. How to void it? Does it need to add as =IF(isblank(a3),"") on Column H or some code in VBA code or using Worksheet_Onentry instead of Worsheet_change?
There is no "On_Entry" event and to be honest, if you are capturing changes to a spreadsheet , it can be as useful to capture deletions as well as insertions. Anyway, here is a tweak of Rob's code to NOT enter the date when something is deleted:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if target.column=1 then
if target.text <> "" then
Application.EnableEvents = False
Target.Offset(0, 7).Value = Format(Date, "dd/mm/yy"
Application.EnableEvents = True
end if
end if
End Sub
Rgds
~Geoff~
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.