Forum Discussion
travisjames.king1
Jul 27, 2018Copper Contributor
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...
- 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 SubRegards
Haytham Amairah
Jul 27, 2018Silver Contributor
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
travisjames.king1
Jul 27, 2018Copper Contributor
Thank you for your quick response!
The code you gave me ALMOST works like I need it to. The issue I am running into is that the cell is still blank until I update the cell (by selecting the cell + backspace and pressing enter) This causes the cell to display the message. Will I need to update every cell manually for the text to appear?
(that would be several thousand cells)