ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I code a cell to display the current date on double-click? (https://www.excelbanter.com/excel-programming/329294-how-do-i-code-cell-display-current-date-double-click.html)

George[_27_]

How do I code a cell to display the current date on double-click?
 
Hi, I want to be able to have the current date entered into a given
cell, when I double-click it.

It will always be a cell, in one particular column, reserved for date.
Jim

Vinit[_2_]

How do I code a cell to display the current date on double-click?
 
Hi,

Write the BeforeDoubleClick of worksheet as follow:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
If Target.Column = 2 Then' for second(B) column
Target.Value = Now()
End If
End Sub

Regards,

Vinit


George wrote:
Hi, I want to be able to have the current date entered into a given
cell, when I double-click it.

It will always be a cell, in one particular column, reserved for

date.
Jim



Patrick Molloy[_2_]

How do I code a cell to display the current date on double-click?
 
If the cell for your date is range named, say "main.date" then your
doubleclick event is easier to follow

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel
As Boolean)
Dim rDate As Range
Set rDate = ThisWorkbook.Names.Item("main.date").RefersToRange
If Target.Address = rDate.Address Then
Cancel = True
Target.Value = Now
End If
End Sub

HTH
Patrick Molloy
Microsoft Excel MVP

"George" wrote:

Hi, I want to be able to have the current date entered into a given
cell, when I double-click it.

It will always be a cell, in one particular column, reserved for date.
Jim


Vinit[_2_]

How do I code a cell to display the current date on double-click?
 
Application.intersect () can also help to check the activecell in a
range


Jim Jones

How do I code a cell to display the current date on double-click?
 

Yes, this example below seems to work just fine.
Please tell me, I'd like to know how to write this stuff, but I can't
learn it on my own. Is there a site or a good book, loaded with such
macro/module examples?

Thanks,
Jim

Hi,

Write the BeforeDoubleClick of worksheet as follow:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
If Target.Column = 2 Then' for second(B) column
Target.Value = Now()
End If
End Sub

Regards,

Vinit


George wrote:
Hi, I want to be able to have the current date entered into a given
cell, when I double-click it.

It will always be a cell, in one particular column, reserved for

date.
Jim




George C.

How do I code a cell to display the current date on double-click?
 
On Fri, 13 May 2005 04:28:18 GMT,
(George) wrote:

Hi, I want to be able to have the current date entered into a given
cell, when I double-click it.

It will always be a cell, in one particular column, reserved for date.
Jim



strive4peace

How do ... display current date on double-click? -- Use Ctrl;
 
Hi George,

why not just use the shortcut key for current date?

Ctrl ; -- Current Date
Ctrl Shift : -- Current Time
Ctrl ;, then SPACE, then Ctrl Shift : -- current date and time together


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



George C. wrote:
On Fri, 13 May 2005 04:28:18 GMT,
(George) wrote:

Hi, I want to be able to have the current date entered into a given
cell, when I double-click it.

It will always be a cell, in one particular column, reserved for date.
Jim




All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com