Automate record timestamp when data in specific range is changed

Xing Duong

New Member
Joined
Feb 2, 2021
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hello everyone,

Need you kind to help me to advise the current code I have used to automatically record the timestamp to work properly.

Current code I have used
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myTableRange As Range
Dim myDateTimeRange As Range
Dim myUpdatedRange As Range

Set myTableRange = Range("D9:O16")

If Intersect(Target, myTableRange) Is Nothing Then Exit Sub

Application.EnableEvents = False
Set myDateTimeRange = Range("F7")
Set myUpdatedRange = Range("F8")

If myDateTimeRange.Value = "" Then

    myDateTimeRange.Value = Now

End If

myUpdatedRange.Value = Now

Application.EnableEvents = True
End Sub

It can work well, except some cells contained the formulas, here are row 11 & 12

Digitized BSOC Template.xlsm
ABCDEFGHIJKLMNO
5Kiến thức cơ bản
6
7Ngày kiểm tra: Tue, 16-Nov-21 13:57
8Ngày cập nhật:Tue, 16-Nov-21 13:57
9
10InitialUnannounced
11Total Scrore:7Total "x": % Score#DIV/0!Result:Incompleted
12Recommended ActionNone
13
14Tên Trainee:
15Tên Trainer:
16Nhận xét:
17
18Tiêu chuẩn trước khi đào tạo
19N/AHoàn thành đào tạo kiến thức nền tảng
20
21Quầy làm việc
22Thiết bị
23N/AĐảm bảo các thiết bị, dụng cụ, vật tư đầy đủ, trong tình trạng tốt và sắp xếp ngăn nắp
24vClean As You Go
25
26Người thực hiên
27vBề ngoài: theo đúng quy định trong Appearance Policy
28vNắm rõ các nguy cơ An Toàn Lao Động và các bước bảo đãm An Toàn Lao Động
29vNắm rõ các nguyên tắc và tiêu chuẩn An Toàn, Vệ Sinh thực phẩm###
30
31Quy trình thực hiện
32Chuẩn bị nguyên liệu
33vXem số lượng cần dùng theo Build To
34vMang bao tay trắng
35Cheese
36Làm nguội (Tempering)
37vLấy cheese trong kho lạnh theo FEFO và FIFO (luôn lấy nguyên bịch)
38
BSOC
Cell Formulas
RangeFormula
F11F11=SUM($Q:$Q)-COUNTIF($A:$A,"N/A")
J11J11=IF(COUNTIF($A:$A,"x")=0,"",COUNTIF($A:$A,"x"))
L11L11=COUNTIF($A:$A,"v")/E11
N11N11=IF(COUNTA($A:$A)-9<SUM($Q:$Q),"Incompleted",IF(L11=100%,"PASS","FAIL"))
H12H12=IF($J$11="","None",IF($J$11=1,"Provide constructive feedback and conduct 2nd verification right then",IF($J$11>=2,"Back to Try-Out stage and conduct 2nd verification right then")))
Named Ranges
NameRefers ToCells
Print_Area=BSOC!$A$5:$O$134N11, L11, J11, F11
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A19:A981Cell Value="N/A"textNO
A19:A981Cell Value="x"textNO
B18:B981Expression=IF(OR($D18<>"",$E18<>"",$F18<>"",$G18<>"",$H18<>"",$I18<>"",$J18<>"",$K18<>""),TRUE,FALSE)textNO
N11:Q11,P12:Q12Cell Value="PASS"textNO
N11:Q11,P12:Q12Cell Value="FAIL"textNO
A19:A981Expression=IF($Q19=1,TRUE,FALSE)textNO
Cells with Data Validation
CellAllowCriteria
E10List, v
J10List, v
A19:A38List=IF($Q19,$R$6:$R$10,"")
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
With:

If myDateTimeRange.Value = "" Then
myDateTimeRange.Value = Now

I believe that next worksheet change event , this range was not blank then Now can not be udated..
 
Upvote 0
With:

If myDateTimeRange.Value = "" Then
myDateTimeRange.Value = Now

I believe that next worksheet change event , this range was not blank then Now can not be udated..
Thanks for your respond.

Actually, I tested changing some cells that are not having formulas in there within a range D9:O16 and it works well. With this said, I think code not applicable for cells with formulas.
 
Upvote 0

Forum statistics

Threads
1,223,941
Messages
6,175,541
Members
452,652
Latest member
eduedu

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