How to check if a year is a leap year in Excel?
Do you know how to determine if a year is a leap year or not? In Excel, there is no direct method for you to check it, but you can create user defined function or formula to solve this problem.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
Supposing you have a list of year in the worksheet, the following long formula can help you to determine if a given year is a leap year or not. Please do as this:
1. Besides the year cells, in a blank cell, enter this formula:
=IF(OR(MOD(A2,400)=0,AND(MOD(A2,4)=0,MOD(A2,100)<>0)),"Leap Year", "NOT a Leap Year"), (A2 contains year that you want to apply this formula, you can change it to your need) see screenshot:
2. Then drag the fill handle over to the range that you want to contain this formula, and all the years have been checked if they are leap years or not.
Note: If the relative cell is blank, this formula will show Leap Year, too.
You can also create User Defined Function to check if the year is a leap year, you can complete it as these:
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: check if a year is a leap year
Function IsLeapYear(pYear As Integer) As Boolean 'Update 20140623 If (pYear Mod 4) = 0 And (pYear Mod 100) <> 0 Or ((pYear Mod 400) = 0) Then IsLeapYear = True Else IsLeapYear = False End If End Function
3. Then save and close this code, go back to your worksheet, and enter this formula: =isleapyear(A2), see screenshot:
4. Then drag the fill handle to the cells that you want to contain this formula, and all the years have been checked off, the FALSE stands for not a leap year and the TRUE indicates a leap year. See screenshot: