Microsoft Excel DateSerial Function | Excel Help
Your Programming and Traning Professionals

Microsoft Excel DateSerial Function


The Excel DateSerial Function is a great function to construct your own date using values inputs you define.

The Basics:

DateSerial( year, month, day)

The required values are self explanatory. Using the Excel DateSerial function you can construct your date.

Now let’s look at an example. Let’s say we want to generate a date value based on the year, month and date values contained on the spreadsheet below.

Code

Dim DateToGenerate As Date  ‘Variable to hold the string to be processed

DateToGenerate = DateSerial(ActiveSheet.Cells(2, 1).Value, ActiveSheet.Cells(4, 1).Value, ActiveSheet.Cells(6, 1).Value)

ActiveSheet.Cells(10, 1).Value = DateToGenerate

Output