Sheet Change Event - Single Execution
Worksheet change event occurs when value in a cell is changed.
The below code will add the time-stamp in the cell next to the cell whose value is changed.
Use case: This can be used when a store wants to track the orders with order number and time-stamp.
Assumption: Column A will have order number and Column B will be updated with the current time-stamp when the column A is updated.
Steps:
1. Open a new file
2. Press Alt+F11 to open VBA editor
3. In the left navigation value select ThisWorkbook
4. In the editor window enter the code below
5. Close the VBA editor
6. Save the file as Macro Enabled File
7. Test with you inputs
Code:
Sub SCESE()
Application.EnableEvents = True
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.EnableEvents = False
r = Target.Row
co = Target.Column
cn = co + 1
Cells(r, cn).Formula = Now()
Call SCESE
End Sub
-Saurabh
- saurabhlakhanpal's blog
- Login or register to post comments
- 3326 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago