VBA Year function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Year Function Description

The VBA Year function returns the year for a provided date (a number from 1900 to 9999).

Syntax

The syntax for the Year function in VBA is:

Year( date)

Parameters

date_value
A date for which the year is to be returned.

Example usage

The Year function can be used in VBA code. Let’s look at some VBA Year function examples:

Year "2015-01-01"
'Result: 2015

Year "2016-02-04 10:00"
'Result: 2016

Dim d as Date 
d = DateValue("2015-02-04 10:00")
Debug.Print Year(d)
'Result: 2015

Simply the best place to learn Excel VBA