nancylynn718
New Member
- Joined
- Jan 14, 2015
- Messages
- 4
Hello,I am very new to VBA and I have basic knowledge of Excel. I have been doing some research and reading up on how to use codes in the VBA but I've run into some issues. I would like to enter the current date by double clicking cells within column A (A3:A1000). I would then like to enter the current time by double clicking cells within columns B (B3:B1000) and F (F3:F10000). I tried to combine the two codes in one but the program would not allow it. As of right now, this is the code I am using for the current time entered on double click:Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)Dim MyRange As RangeDim IntersectRange As RangeSet MyRange = Application.Union( _ ActiveSheet.Range("B3:B1000"), _ ActiveSheet.Range("F3:F1000"))Set IntersectRange = Intersect(Target, MyRange)On Error GoTo SkipItIf IntersectRange Is Nothing ThenExit SubElseActiveSheet.UnprotectApplication.ScreenUpdating = FalseTarget = Format(Now, "ttttt")ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=TrueActiveSheet.EnableSelection = xllockedCellsEnd IfActiveSheet.UnprotectRows("1:3").SelectRange("1:3,A4:E65536").SelectRange("1:3,A4:E65536,G4:IV65536").SelectSelection.Locked = FalseSelection.FormulaHidden = FalseActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _FalseActiveCell.Offset(, 1).SelectSkipIt:Exit SubEnd SubThe second portion of the code is in place because I was having some issues using the filters. Can anyone help me and let me know how to add to this code so I can add the current date by double clicking cells in column A (A3:A1000)? Thank you for your assistance.