VBA - Date and Time

There is a dedicated datatype fro storing date and times.  This is the "date" datatype.

In this example we use the "Now()" function to get the time and date now,

we then reassign the variable as "Time" which just assigns the time.

Code Snippet:

Sub a4_5_Date()

Dim x As Date

x = Now()

MsgBox x

x = Time

MsgBox x

End Sub




Related Sections

Python - Learn the python from the basics up. This fast track example code course will get you creating powerful python programs in no time.



Must Read Articles


VBA and Microsoft Excel - Getting the most out of excel with VBA programming
VBA and Microsoft Word - Getting the most out of word with VBA programming
Application Object - Using the applications features in your code.

Installing VBA and First Program - What do you need to start using visual basic application VBA.