PDA

View Full Version : adding date with double click



aoc
04-09-2007, 12:31 PM
hi,

how can I add the day and month like 29.03 when I double click any cell in column D ?

regards

Charlize
04-09-2007, 12:54 PM
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Selection.Count > 1 Then Exit Sub
If Target.Column = 4 Then
Target.NumberFormat = "dd/mm"
Target.Value = Date
Cancel = True
End If
End SubCharlize

Simon Lloyd
04-09-2007, 12:58 PM
Hi, format column D as custom and then dd.mm then add this to the worksheet code module:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("D:D")) Is Nothing Then
Target.Value = Date
Cancel = True
End If
End Sub
Regards,
Simon

aoc
04-09-2007, 01:07 PM
hi,

charlize's and yours does not work, what is the problem ?

Simon Lloyd
04-09-2007, 01:16 PM
Works fine for me!, post your workbok or example workbook!

aoc
04-09-2007, 01:20 PM
hi,

please check the attached file.code is in module 4

regards

aoc
04-09-2007, 01:46 PM
hi,

charlizes works.I changed the place of code.yours has format problem

thanks

Simon Lloyd
04-10-2007, 01:45 AM
Aoc, the code supplied by both myself and Charlize was to be placed in the Worksheet code module NOT a standard module as per our instructions!

Regards,
Simon