A few words of thanks would be greatly appreciated.

Cell input to call macro in adjacent cell


I have a scenario that i'd like automated. The scenario is as follows

If i enter a value in any cell in a particular column, i want the system time to be entered in the adjacent cell. Currently i have used this command in a macro to do it, but it is a manual process (ActiveCell.Value = Time) and i have to click on the adjacent cell and then press the shortcut buttons to do it every time.


If i enter 123 in cell A2, then i want the system time (eg. 6:59:33 PM) to be captured in cell B2. I want to continue entering values in the column 'A' one below the other with system time being automatically entered down to the second in the corresponding adjacent cell in column 'B'. Is this possible, it would be awesome if someone could help me.


Implement this code on the worksheet you want it to work on (right click on the worksheet tab, click on view code):

Private Sub Worksheet_Change(ByVal Target As Range) 
ActiveCell.Offset(-1, 1) = Time 
End Sub

Whenever you put something in a cell and hit ENTER, the current system time is being put in the adjacent cell to the right.


NOTE that you have to confirm your entry by hitting ENTER and not use the arrows or TAB.

Thanks to Trowa for this tip on the forum.


A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Cell input to call macro in adjacent cell », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).