我想创建一个子列表,在列表中记录您在当前会话中按下返回键的次数(每次重新打开文件时应该在新行上写入) 继承人是我的尝试: 不知怎的,它不起作用
Option Explicit
Private Sub Worksheet_activated(ByVal target As Range)
Target.Value = target.Value + 1
Application.OnKey "~", "CountDT"
End Sub
Private Sub worksheet_deactivated()
Application.OnKey "~"
End Sub
Option Explicit
Sub CountDT()
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = ActiveCell.Value & " " & Date & " " & Time
End Sub
答案 0 :(得分:0)
在工作表代码模块中:
Option Explicit
Private Sub Worksheet_Activate()
Application.OnKey "~", Me.CodeName & ".CountDT"
End Sub
Private Sub Worksheet_Deactivate()
Application.OnKey "~"
End Sub
Sub CountDT()
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = ActiveCell.Value & " " & Date & " " & Time
End Sub