Forum Discussion
Double click to add date to cell
- 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
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.king1Jul 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)
- travisjames.king1Jul 27, 2018Copper Contributor
I got it! sorry for the dumb question. Thank you everything works perfectly i just have to drag the cell with the plus sign thing and it updates each cell. Thank you very much again for the help, the sheet is exactly like i want it for now:)
- Haytham AmairahJul 27, 2018Silver Contributor
You're welcome!
Don't hesitate to refer back to me if you have any further issues!
Regards