TOP

VBA Function: Now

Description

The VBA Now function returns the current system date and time.


Now Syntax

Now

VBA Now Example

Save the date returned by the Now function in cell A1:

Sub NowExample1()

      Range("A1") = Now
    
End Sub

Display the date returned by the Now function in text format:

Sub NowExample2()

      MsgBox Format(Now, "d mmmm yyyy hh:nn") 'Returns, for example: 2 November 2020 13:08
    
End Sub

Perform the action only if it is at least 5:00 pm and it is a weekday:

Sub NowExample3()

      If Hour(Now) >= 17 And Weekday(Now, vbMonday) < 6 Then
          MsgBox "The workday is almost over!"
      End if
    
End Sub
The function that returns only the current date (no time) is the DATE function.
The TIME function returns only the current time (no date) .