Date and Time that a cell was populated

SwimmingNathan

New Member
Joined
Aug 21, 2013
Messages
34
Hey hey,

Is there a way for a date and time to be added into say B1 when any data is added into A1?

I could swear I've had this running before, when I've been adding rows of contacts, in order to let me know what dates batches were added.

I cannot for the life of me remember/ figure out how though now..!

Any help is greatly appreciated.

Cheers,

Swimming
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Give this a try
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range
    
        ' The variable KeyCells contains the cells that will
        ' cause an alert when they are changed.
        Set KeyCells = Range("A1")
        
        If Not Application.Intersect(KeyCells, Range(Target.Address)) _
               Is Nothing Then
    
            ' Display a message when one of the designated cells has been
            ' changed.
            ' Place your code here.
            With Target.Offset(0, 1)
                .Value = Now()
                .NumberFormat = "[$-409]d-mmm-yyyy hh:MM:ss AM/PM"
            End With
        End If

End Sub
 
Upvote 0
Thanks for that, I'll try to get it to work, I'm not a master of VBA though, weird thing is I'm sure I've done this without even using a formula!
 
Upvote 0
The code above (harvested from a Microsoft KB on the topic and tweeked minorly) will meet the need you describe in the original question. Just change the KeyCells range to include whatever cells you want the macro to watch and act on. If you wanted the macro to act whenever any cell in column C is changed, you might change it to
Code:
        Set KeyCells = Range("C:C")
(as an example).
 
Upvote 0
Ok thank you again, like I said I'm not a master of VBA (or Excel for that matter) how do I set which cell the date and time will be displayed in?
 
Upvote 0
The offset part tells it where to put the timestamp. Offset(0,1) means that when a target cell is changed, the date/time will go in the cell 0 rows down and 1 cell to the right.

Glad I could help
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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