Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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.

Check if a year is a leap year with formula

Check if a year is a leap year with User Defined Function


arrow blue right bubble Check if a year is a leap year with formula


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:

doc-check-if-leap-year-1

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.

doc-check-if-leap-year-1

Note: If the relative cell is blank, this formula will show Leap Year, too.


arrow blue right bubble Check if a year is a leap year with User Defined Function

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:

doc-check-if-leap-year-1

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:

doc-check-if-leap-year-1


Related article:

Find the lowest common denominator or greatest common factor in Excel


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!

 

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    ivec · 1 years ago
    What 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.
    SteveV · 3 years ago
    Please don't post my previous comment.
  • To post as a guest, your comment is unpublished.
    SteveV · 3 years ago
    Using Excel 2013 the VBA returns backwards, saying 2015 is a leap year and 2016 is not