VBA Function: Now

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

Usage:

Now


Examples of Usage

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

Sub example()

    Range("A1") = Now
    
End Sub

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

Sub example()

    MsgBox Format(Now, "mmmm d yyyy h:nn AM/PM") 'Returns, for example: June 15 2024 2:12 PM
    
End Sub

Perform an action only if it is at least 5:00 PM and a weekday:

Sub example()

    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 (without the time) is the Date function.
The function that returns only the current time (without the date) is the Time function.