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:
You are guest
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 5 months agoivec, your determination of a leap year within Excel itself works if the year is at / later than the Excel base year of 1900. For years before the Excel base year of 1900, I believe an external determination is required.
To post as a guest, your comment is unpublished.· 3 years agoWhat about relying on Excel's own definition of a leap year?
The expression below checks the difference between March 1st and Feb 28 in that year - a leap year will have Feb 29 in-betweek, which makes a difference of 2 days.
IsLeapYear formula: = ( DATE( $$YEAR_REF$$ ;3;1)-DATE( $$YEAR_REF$$ ;2;28) > 1.5 )
The 1.5 is because I'm not sure if there is a risk of floating-point inaccuracies...
To post as a guest, your comment is unpublished.· 5 years agoPlease don't post my previous comment.
To post as a guest, your comment is unpublished.· 5 years agoUsing Excel 2013 the VBA returns backwards, saying 2015 is a leap year and 2016 is not