Cell input to call macro in adjacent cell

April 2018


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.
Published by aakai1056. Latest update on November 18, 2009 at 09:16 AM by aakai1056.
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 (https://ccm.net/).
Excel - Arrow keys stopped working
How to split data into multiple worksheets?