Return to VBA Code Examples

VBA Year Function

Year Description

Returns a four-digit year (a number from 1900 to 9999) given a date value.

Simple Year Examples

Here is a simple Year example:

This code will return 2019.

Year Syntax

In the VBA Editor, you can type  “Year(” to see the syntax for the Year Function:

The Year function contains an argument:

Date: A valid date.

Examples of Excel VBA Year Function

Result: 1999

Result: 2001

Result: 1905

Result will be the year of the current system date.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as

Learn More!