Consulting

Results 1 to 2 of 2

Thread: Obtaning current date time through VBA

  1. #1

    Obtaning current date time through VBA

    I would like to get current date and time with following format ""13-Feb-2005 17:19"". Is there any VBA code to get that?

    Best regards,

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    By example, for A1 of current sheet, try:
    [vba]Option Explicit

    Sub exa()
    With Range("A1")

    .NumberFormat = "d-mmm-yyyy Hh:Mm"
    '// to return now
    '.Value = Now()

    '//to return ex date/time
    .Value = DateSerial(2005, 2, 13) + TimeSerial(17, 19, 0)

    .EntireColumn.AutoFit
    End With
    End Sub[/vba]

    Hope that helps,

    Mark

Posting Permissions

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