Forum Discussion

travisjames.king1's avatar
travisjames.king1
Copper Contributor
Jul 27, 2018
Solved

Double click to add date to cell

Hello, I was able to figure out how to make it so you can add the date to cell with the following code   Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)     If No...
  • Haytham Amairah's avatar
    Jul 27, 2018

    Hi,

     

    Please try these two methods in the worksheet code module:

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("E2:G71")) Is Nothing Then
            Cancel = True
            Target.Formula = Date
        End If
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("E2:G71")) Is Nothing Then
            If Not IsDate(Target) Then
                Target.Value = "double click to add date"
            End If
        End If
    End Sub

     

    Regards

Resources