Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Q. How do I code a column to insert current date, when I double-click?

Hi,
I have a spreadsheet, where I'd like the date column to enter the
current date, when I double-click on that particular cell. It will
always be a cell, in the column labeled "Date".
Thanks,
Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Q. How do I code a column to insert current date, when I double-click?

Jim/George,

In the codemodule of the thisworkbook object, insert the code below.

Un-comment the line
'Cancel = True
if you don't want to stay in edit mode after the double-click.

Change the format to your desired style from the mmm dd, yyyy, and you're
done.

HTH,
Bernie
MS Excel MVP

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, _
ByVal Target As Range, Cancel As Boolean)
If IsError(Application.Match("Date", _
Target.EntireColumn, False)) Then Exit Sub
Application.EnableEvents = False
Target.Value = Date
Target.NumberFormat = "mmm dd, yyyy"
Target.EntireColumn.AutoFit
Application.EnableEvents = True
'Cancel = True

End Sub


"George" wrote in message
...
Hi,
I have a spreadsheet, where I'd like the date column to enter the
current date, when I double-click on that particular cell. It will
always be a cell, in the column labeled "Date".
Thanks,
Jim



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Q. How do I code a column to insert current date, when I double-click?

Try these:
Assume column A is the date column

' This one works on double click. The select portion is to exit the cell
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column = 1 Then
Target = Date
Target.Offset(0, 1).Select
End If
End Sub

' This one works on a single click, but will also fire with any selection
change.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 1 Then
Target = Date
End If
End Sub


--
steveB

Remove "AYN" from email to respond
"George" wrote in message
...
Hi,
I have a spreadsheet, where I'd like the date column to enter the
current date, when I double-click on that particular cell. It will
always be a cell, in the column labeled "Date".
Thanks,
Jim



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Q. How do I code a column to insert current date, when I double-click?

Why not use Cancel in the double click event as stated by Bernie? Probably
better to use the features provided.

--
Regards,
Tom Ogilvy

"STEVE BELL" wrote in message
news:Rsipe.12888$yS2.107@trnddc07...
Try these:
Assume column A is the date column

' This one works on double click. The select portion is to exit the cell
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column = 1 Then
Target = Date
Target.Offset(0, 1).Select
End If
End Sub

' This one works on a single click, but will also fire with any selection
change.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 1 Then
Target = Date
End If
End Sub


--
steveB

Remove "AYN" from email to respond
"George" wrote in message
...
Hi,
I have a spreadsheet, where I'd like the date column to enter the
current date, when I double-click on that particular cell. It will
always be a cell, in the column labeled "Date".
Thanks,
Jim





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Q. How do I code a column to insert current date, when I double-click?

Tom,

How right you are!

--
steveB

Remove "AYN" from email to respond
"Tom Ogilvy" wrote in message
...
Why not use Cancel in the double click event as stated by Bernie?
Probably
better to use the features provided.

--
Regards,
Tom Ogilvy

"STEVE BELL" wrote in message
news:Rsipe.12888$yS2.107@trnddc07...
Try these:
Assume column A is the date column

' This one works on double click. The select portion is to exit the cell
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column = 1 Then
Target = Date
Target.Offset(0, 1).Select
End If
End Sub

' This one works on a single click, but will also fire with any selection
change.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 1 Then
Target = Date
End If
End Sub


--
steveB

Remove "AYN" from email to respond
"George" wrote in message
...
Hi,
I have a spreadsheet, where I'd like the date column to enter the
current date, when I double-click on that particular cell. It will
always be a cell, in the column labeled "Date".
Thanks,
Jim







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I code a cell to display the current date on double-click? George[_27_] Excel Programming 6 December 10th 06 09:26 AM
Need to double-click for data to be recognised as date?! HierkommtdieMau Excel Discussion (Misc queries) 3 March 28th 06 11:17 AM
double click insert date Slobodan Excel Worksheet Functions 1 February 16th 06 01:28 PM
double click a cell with Date format qqxz Excel Discussion (Misc queries) 1 January 24th 06 02:41 PM
Double-click date entry RJH Excel Programming 2 January 30th 04 04:41 PM


All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"