volabos
02-12-2010, 01:48 PM
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,
: pray2:
By example, for A1 of current sheet, try:
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
 
Hope that helps,
 
Mark
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.