Enter "today's" date when data entered into a specific cell?

MikeyW1969

Board Regular
Joined
Apr 28, 2014
Messages
80
Hi guys,
I'm setting up an Excel sheet to maintain a spreadsheet for asset management. We have an asset management system in place, but there are occasional times where it's offline(Or I am), so I wanted to make something that I could chart these items on, and I wanted to get a little fancy.

So I have a column for things like the user's name, the type of asset, the make/model., etc...

I would like to have the date auto-fill with the current date, when I enter something in the 'Name' column, which happens to be 'A'. The 'Date' column is 'B'. So what I'm looking for is when I enter anything in the 'Name' Field(Say the first row is "2", the next one would be "3", etc.), it would autofill in the date column next to it. So, if A2 contains my first user's name, B2 would have today's date. When I enter the next person, then that person's name would be in A3, and B3 would be where that particular date is.

Later, I would do the same for the date when I went back and added it to the asset management system and "closed" that entry, but if I learn how to do the first one, the next one will be easy. Any help would be greatly appreciated.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Count > 1 Then Exit Sub
  If Target.Column = 1 Then
    If Target.Value = "" Then Exit Sub
    Target.Offset(, 1).Value = Date
  End If
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.

Return to the excel sheet, type something in cell A2, the date will automatically be set in cell B2.
 
Upvote 0
OK, so this one worked beautifully.

For the 'A' column. I figured that i just needed to change the
Code:
If Target.Column = 1 Then
line to '8' or something(For the 8th column), to do the second date entry farther down the list, but that didn't work. What am I missing? Or does having two different areas with the possible date entry completely change the thing?
 
Upvote 0
OK, so this one worked beautifully.

For the 'A' column. I figured that i just needed to change the
Code:
If Target.Column = 1 Then
line to '8' or something(For the 8th column), to do the second date entry farther down the list, but that didn't work. What am I missing? Or does having two different areas with the possible date entry completely change the thing?

If you want it to work for columns A and H and set the date to B and I respectively, then try this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Count > 1 Then Exit Sub
  If Not Intersect(Target, Range("A:A, H:H")) Is Nothing Then
    If Target.Value = "" Then Exit Sub
    Target.Offset(, 1).Value = Date
  End If
End Sub
 
Upvote 0
That was perfect! Thanks again.

I love this site, everyone has a different way to approach the issue, and all of the suggestions work. This one will be perfect. Thanks!
 
Upvote 0
That was perfect! Thanks again.

I love this site, everyone has a different way to approach the issue, and all of the suggestions work. This one will be perfect. Thanks!

I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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