View Single Post
  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default How to auto-enter date when cell is clicked?

Do you want to check the entry, and if already present as a date, don't
overwrite? If so


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ans As Long
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Column = 12 And .Row = 4 Then
If Not IsDate(.Value) Then
.Value = Format(Date, "dd mmm yyyy")
End If
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ron M." wrote in message
oups.com...
Bob: that works, but some people have trouble with it. They click on
the cell and the date appears, true, but then if they hit return or
enter or the down or up arrow, it puts the date in THAT cell, too. If a
date was previously entered in that cell, it replaces it with the
current one.

I dunno, I think we'll just have to go with control-; .

Thanks,
Ron M.