automatically date a cell when entering data in adjoining cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like Excel to automatically date, with today's date, when the
adjoining cell recieves data: ie date C3 when D3 recieves data. Is this
possivble?
 
Here is an old post of mine that lays it out:

If you are asking how you would do it in code.

Right click on the sheet tab for that sheet. Select view code. In the left
dropdown, select worksheet, in the right, Change.


This sub will appear:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)


End Sub


You can put in code like this


Assume you will enter the name in Cell B5 and you want the date put in cell
C5


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$C$3" Then
If Len(Trim(Target.Value)) > 0 Then
Target.Offset(0, 1).NumberFormat = "mm/dd/yyyy"
Target.Offset(0, 1).Value = Date
Target.Offset(0, 1).EntireColumn.AutoFit
End If
End If
End Sub


If you want this to happen if anything is entered in column C


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if target.column = 3 then
If Len(Trim(Target.Value)) > 0 Then
Target.Offset(0, 1).NumberFormat = "mm/dd/yyyy"
Target.Offset(0, 1).Value = Date
Target.Offset(0, 1).EntireColumn.AutoFit
End If
End if
End Sub


Regards,
Tom Ogilvy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top