Automatic date entry

daveray

New Member
Joined
Mar 3, 2002
Messages
28
Is there a way to automatically enter a date into a worksheet. I have a sheet with the date in coloumn D. What I would like is a way of the date being entered as soon as a value is entered into column A.

Unfortunately, I also need that date to stay permanently even if the original entry in A is edited at a later date.

For example a salesman could bring a deal into the office and it could be logges in the sheet. If that salesman leaves or if another salesman amends the deal resulting in a different name being entered into A I don't want the original date in D to change.

Is it possible?

Dave
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Either would do Jack.

VBA would be interesting as I am trying to get into that more.

Thanks in anticipation.

Dave
 
Upvote 0
You could right click on the sheet in question, click view code and enter the following vba:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns(1)) Is Nothing Then
    If Target.Offset(, 3).Value = Empty _
    And Target <> "" Then
    Target.Offset(, 3).Value = Date
    End If
End If
End Sub

You must make sure your events are enabled. Hope this helps.
 
Upvote 0
In the Worksheet module for the concerned sheet, insert the following code:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Col = Target.Column
Dim Temp As Range
If Col = 1 Then
Set Temp = Target.Offset(0, 3) 'For col. D:D
If IsEmpty(Temp) Then Temp = Now()
Temp.NumberFormat = "mmm dd, yyyy" 'Or whatever date format you like
End If
End Sub


or the other way can be:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 1 Then
If Target.Offset(0, 3).Text = "" Then
Target.Offset(0, 3).Value = Now
End If
End If
End Sub
 
Upvote 0
So many ways to skin a cat :eek:)

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Not IsDate(Target(1, 4)) Then
Target.Cells(1, 4) = Date
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,378
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top