简体   繁体   English

记录数据时自动更新日期

[英]Update Date automatically when I log data

I have been filling out an excel sheet logging project information. 我一直在填写Excel工作表记录项目信息。 I would like to know how to have to populate a cell with the current date when I update cells in the adjacent row in the same sheet. 我想知道在更新同一张纸的相邻行中的单元格时,如何用当前日期填充一个单元格。 There is currently information in the adjacent cells but I want it to hold the date that I previously updated it with. 当前在相邻的单元格中有信息,但我希望它保留以前更新它的日期。 Only when I update the information I want it to change 只有当我更新信息时,我才希望更改它

I have googled for logical operator information but I cannot seem to find a direct answer. 我已经在Google上搜索了逻辑运算符信息,但似乎找不到直接答案。 If there is a VB macro I could I am open to any solutions. 如果有VB宏,我可以接受任何解决方案。 I have found information on the TODAY() function in excel as well but I do not know how to apply it my particular problem. 我也在Excel中也找到了关于TODAY()函数的信息,但是我不知道如何将其应用于我的特定问题。 Any references to VB macros or information would be helpful. 对VB宏或信息的任何引用都将有所帮助。 Thank you. 谢谢。

Try this, Alt-F11 to launch the editor, right-click "Sheet1" (or your sheet name) and select add code, paste in something like this: 尝试使用Alt-F11来启动编辑器,右键单击“ Sheet1”(或您的工作表名称),然后选择添加代码,并粘贴如下内容:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    Set KeyCells = Range("B2:B10")

    If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
        Cells(Target.Row, Target.Column - 1) = Now()
    End If
End Sub

If you type something into B2 to B10 then the adjacent column is updated with the current date. 如果在B2到B10中键入内容,则相邻列将使用当前日期更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更新 B 到 Z 范围内的数据时,自动更新 A 列中的日期和时间数据 - Automatically update date and time data in column A when updating data in the range from B to Z 数据更改时图表不会自动更新 - Charts Do Not Automatically Update When Data Changes 当单元格中的值更改时,私有子更新日期自动 - Private sub update date automatically when value in a cell changes 如何在PowerPoint中自动进行未来日期更新? - How can I have a FUTURE date update automatically in PowerPoint? 如何在 excel 中自动创建和更新月份日期列表? - How do I automatically create and update month date list in excel? 将数据粘贴到其他列时自动将日期输入单元格 - Automatically enter date into cell when data is PASTED into other column 更改数据时使我的VBA代码自动更新 - Making my VBA Code update automatically when data is changed 在数据中添加新的列和行时,Excel自动更新图形 - Excel automatically update graph when adding new columns and rows in data 使用数据验证更改一个单元格后,如何自动更新单元格以匹配另一个工作表中的值? - How do I automatically update cells to match values from another sheet when one cell is changed using data validation? 自动更新数据透视表数据源 - Automatically update PivotTable data source
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM