Home count and record number of times i press the enter key
Reply: 1

count and record number of times i press the enter key

Francoise Eric
1#
Francoise Eric Published in 2018-02-14 15:45:10Z

i want to create a sub that records in a list how many times you pressed the return key in the current session (it should write on a new line each time you reopen the file) heres are my attempts: somehow it's not working

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
Tim Williams
2#
Tim Williams Reply to 2018-02-15 07:03:13Z

In the worksheet code module:

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
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.296982 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO