Date

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

i would like to be able to automatically put the current date in the
cell only when something is entered into another cell, but I when I go
back to the worksheet I don't want that date to update to the current
date I just want it to show the date that the information was entered.
 
right click on the tab name of the sheet (say sheet1). click on view-code.
When the VBE opens, enter the following code:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$B$1" Then
' Range("A1") = Date ' only date
Range("A1") = Now() ' date + time
End If

End Sub

This will enter the date in A1 when you enter something in B1

Mangesh
 
Thank you that helped alot, now how could a write that for a range of
cells, I am now officially a newbie to excel VBA code, seems pretty
easy to learn, a bit like VB and C++, but those are the only
programming codes I have really learned, except for microprocessor
stuff.
 
No, the formula would update the date daily, which is specifically stated as
not wanted by the OP.
 
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B1:H10")) Is Nothing Then
With Target
Target.Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub
 
This all works but I would like the date to show in the cell next to
the date something is entered. When B3 to B26 has something entered,
the date will show in C3 to C26, respectively.
 
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B3:B26")) Is Nothing Then
With Target
Target.Offset(0,1).Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub
 
Back
Top