• 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.

Entering current time

Alechko

New Member
Hello to all forum dwellers!
Please advice. I have an excel table with workers name and when did they start to install the appliance or whatever. I need to define a specific range of cells (not each cell), which by double clicking on it, current time is shows up.
Ihave this code below, but it's only for one E1 cell:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$E$1" Then
Target.Value = Time
End If
End Sub
 
Alechko,

try this one:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not (Intersect(Target, Range("$E$1:$E$5")) Is Nothing) Then
Target.Value = Time
End If
End Sub
 
Hi People!
Thanx a lot for helping me! I need the range or square from C4:C200 (and sometimes more) to X4:X200
 
To setup a dynamic range starting at C4, would be:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim lastRow As Long
With Me
    'Find the last row in col C that is used
    lastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
End With
If Not (Intersect(Target, Range("C4:X" & lastRow)) Is Nothing) Then
    Target.Value = Time
    Cancel  = True 'So user isn't still editing cell
End If
End Sub
 
Back
Top