+ Reply to Thread
Results 1 to 5 of 5

Command Button Date/Time Stamp

Hybrid View

  1. #1
    sky
    Guest

    Command Button Date/Time Stamp

    I am trying to date/time stamp a cell by clicking a command button. I want
    the cell to display the date and time when the button was last clicked. I can
    get it to display the date but I cannot figure out how to get "SendKeys" to
    allow me to select CTL+; "SPACE" CTL+ALT+; . This is what I have now as a
    command for the button and it will give me a date in the selected cell:

    Private Sub CommandButton1_Click()
    Range("c2").Select
    SendKeys "^("
    End Sub
    --
    skyknight

  2. #2
    Norman Jones
    Guest

    Re: Command Button Date/Time Stamp

    Hi Sky,

    Try:

    '=============>>
    Private Sub CommandButton1_Click()
    ActiveCell.Value = Format(Now, "mm/dd/yy hh-mm")
    End Sub
    '<<=============


    ---
    Regards,
    Norman



    "sky" <sky@discussions.microsoft.com> wrote in message
    news:A7F16C2F-5BA5-4E25-9216-A4BEF8D8E565@microsoft.com...
    >I am trying to date/time stamp a cell by clicking a command button. I want
    > the cell to display the date and time when the button was last clicked. I
    > can
    > get it to display the date but I cannot figure out how to get "SendKeys"
    > to
    > allow me to select CTL+; "SPACE" CTL+ALT+; . This is what I have now as a
    > command for the button and it will give me a date in the selected cell:
    >
    > Private Sub CommandButton1_Click()
    > Range("c2").Select
    > SendKeys "^("
    > End Sub
    > --
    > skyknight




  3. #3
    Jim Thomlinson
    Guest

    RE: Command Button Date/Time Stamp

    Private Sub CommandButton1_Click()
    Range("c2").Value = Now()
    End Sub

    --
    HTH...

    Jim Thomlinson


    "sky" wrote:

    > I am trying to date/time stamp a cell by clicking a command button. I want
    > the cell to display the date and time when the button was last clicked. I can
    > get it to display the date but I cannot figure out how to get "SendKeys" to
    > allow me to select CTL+; "SPACE" CTL+ALT+; . This is what I have now as a
    > command for the button and it will give me a date in the selected cell:
    >
    > Private Sub CommandButton1_Click()
    > Range("c2").Select
    > SendKeys "^("
    > End Sub
    > --
    > skyknight


  4. #4
    sky
    Guest

    RE: Command Button Date/Time Stamp

    Thanks Guys
    I finally also came up with my own less elegant one.
    ===========
    Private Sub CommandButton1_Click()
    Range("c2").Select
    SendKeys "^("
    SendKeys " "
    SendKeys "^+(", Wait
    End Sub
    =========
    skyknight




  5. #5
    Norman Jones
    Guest

    Re: Command Button Date/Time Stamp

    Hi Sky,

    > I finally also came up with my own less elegant one.


    Elegance is in the eye of the beholder, but why use a clunky implementation
    of SendKeys when a native function is available?

    ---
    Regards,
    Norman


    "sky" <sky@discussions.microsoft.com> wrote in message
    news:BD619594-D101-445F-AB30-F77316128A81@microsoft.com...
    > Thanks Guys
    > I finally also came up with my own less elegant one.
    > ===========
    > Private Sub CommandButton1_Click()
    > Range("c2").Select
    > SendKeys "^("
    > SendKeys " "
    > SendKeys "^+(", Wait
    > End Sub
    > =========
    > skyknight
    >
    >
    >




+ 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