+ Reply to Thread
Results 1 to 5 of 5

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

  1. #1
    George
    Guest

    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

  2. #2
    Vinit
    Guest

    Re: 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



  3. #3
    Patrick Molloy
    Guest

    RE: 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
    >


  4. #4
    Vinit
    Guest

    Re: 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


  5. #5
    Jim Jones
    Guest

    Re: 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

    >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1