excel - 使用数据时间戳和值跟踪单元格的值变化
问题描述
我目前正在开发 Excel VBA 上的需求管理工具。
在 GI 列中有需求的状态(待办事项、待处理、正在进行的工作、已完成),在 MI 列中希望在用户更改值时自动跟踪状态的变化。
我想要获得的是类似“状态从”& [state t] & “to” & [state t+1] & “on” & [timestamp] 示例:“状态从正在进行的工作更改为完成2019/09/05 - 15:30"
我是 VBA 的初学者,所以我不知道从哪里开始这项任务......
提前致谢!
解决方案
You need to attach code to the sheet_change event. This is called every time the sheet changes. The code needs to check if the cell that changed is in your target column (G) and if so, write the appropriate value into the adjacent cell in column M. To attach code to an event it has to be in the sheet module of the appropriate sheet. Start the VB editor by pressing Alt-F11. In the project explorer double click on the appropriate sheet to open up the sheet module. Paste the following code into that module.
Private Sub Worksheet_Change(ByVal Target As Range)
if target.column = 7 then 'if column G then...
Application.EnableEvents = false 'stop tracking changes
Cells(target.row,13) = "State changed on " & format(date(),"yyyy/mm/dd hh:mm")
Application.EnableEvents = true
End If
End Sub
推荐阅读
- angular - 从 .json/.xml 读取数据并在 Angular 中填充列表
- ios - 转移 iOS 应用并希望使用 Auth Key 发送推送通知
- sql-server - 卡在获取交易价值的计算
- oracle - 登录名和密码相同
- jenkins - Jenkins 警告下一代插件:Java 编译器警告被忽略 - 为什么?
- solr - 当提升的术语出现在多个字段中时,solr 中的查询字段提升问题
- android - 如何修复 TextInputLayout 中的“文本提示”?
- python-3.x - 排除不包含文本文件中的一个或多个字符串的行
- javascript - Ngrx/store - 使用类的动作创建者与使用工厂功能的动作创建者?
- java - 运算符 || 不能包含在 int 中?