如何让EXCEL自动检测单元格是否有字符并自动插入当前日期

2024-12-23 01:41:33
推荐回答(3个)
回答1:

需要用vba

按ALT+F11,双击thisworkbook,粘贴下面的代码

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
With Target
.Value = .Value & Format(Now, " yyyy-mm-dd hh:mm:ss")
End With
Application.EnableEvents = True
End Sub

回答2:

刚刚的公式有误

回答3:

辅助列公式为“=IF(B2="","",NOW())”
并将列格式设为日期时间型