+ Reply to Thread
Results 1 to 6 of 6

Thread: Date/time Macro

  1. #1
    Forum Contributor TheRetroChief's Avatar
    Join Date
    09-30-2008
    Location
    UK
    MS-Off Ver
    2003
    Posts
    128

    Date/time Macro

    Greetings,
    What is the code i need to use to assign a macro to a command button which inserts the current date and time in the selected cell regardless of where that cell is?
    Much obliged.
    Last edited by TheRetroChief; 10-20-2009 at 08:13 AM.

  2. #2
    Registered User
    Join Date
    03-16-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Date/time Macro

    Code:
    Sub Macro6()
    '
    ' Macro6 Macro
    '
    
    With ActiveCell
        .NumberFormat = "[$-409]m/d/yy h:mm AM/PM;@"
        .Value = Now()
        .ColumnWidth = 15#
    End With
    End Sub
    Last edited by radar_jynx; 10-20-2009 at 07:13 AM.

  3. #3
    Registered User
    Join Date
    03-16-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Date/time Macro

    Just edited, had a typo try that. You may need to increase the column width.

  4. #4
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    5,826

    Re: Date/time Macro

    Hi,

    One way:
    Code:
    ActiveCell = Format(Date, "dd/mm/yyyy") & " : " & Time
    HTH
    Richard Buttrey

    If this was useful then please rate it appropriately.

    Click the small star icon at the bottom left of my post.

  5. #5
    Registered User
    Join Date
    10-14-2009
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    3

    Arrow Re: Date/time Macro

    hi buddy,

    find the attachment it will be fix ur pblm
    regards,

    Prabath.N
    Attached Files Attached Files

  6. #6
    Forum Contributor TheRetroChief's Avatar
    Join Date
    09-30-2008
    Location
    UK
    MS-Off Ver
    2003
    Posts
    128

    Thumbs up Re: Date/time Macro

    As always, you guys have sorted me right out.
    Ta muchly.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0