• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel Macro

chowdary2005

New Member
Chandoo Please help in writing a macro.


I want a macro which restricts/ protects work book from user from entering data except accepting the

key strokes ctrl+Shift+: which inserts current time into the highlighted field.
 
You'll need to insert a modele into your workbook, and then paste in these 3 macros. You can then either save, close, and reopen your workbook, or just run the Auto_Open macro to get things started.

[pre]
Code:
Sub Auto_Open()
Application.OnKey "^+:", "TimeStamp"
'Sets up the keyboard shortcut
End Sub

Sub Auto_Close()
Application.OnKey "^+:"
'Unloads the keyboard shortcut
End Sub

Sub TimeStamp()
ActiveSheet.Unprotect
On Error Resume Next
ActiveCell.Value = Now
On Error GoTo 0
ActiveSheet.Protect

'If your workbsheet has a password, you need to include that in the protect/unprotect
'line of code like this
'ActiveSheet.Unprotect "MyPassword"
'ActiveSheet.Protect "Password"
End Sub
[/pre]
 
Back
Top