Display all next 20 years leap year vba

vbvba

New Member
Joined
May 25, 2012
Messages
34
Hi Guys,

I would like to know how to print next 20 leap years in vba program

I have a function to find leap year as below, but how to print the years in excel A column can you help me ?

Public Function isLeapYear()


' returns FALSE if not Leap Year, TRUE if Leap Year
isLeapYear = (Month(DateSerial(Yr, 2, 29)) = 2)




End Function
 
Speed-wise, faster than 7000 calculations.
My macro takes approximately 3/100 of a second to execute, which is some 10 times faster than the "blink of an eye", so I am not sure speed would (should) be an issue.


Many of us of us will not be around for the next 20 leap years.
I am kind of hoping I will be. Of course if I am, I will more than likely have the distinction of being the oldest human being at nearly 149 years old. Yes, I know... unlikely... but I am holding out hope.:laugh:
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hello,

Thank you very much for putting this out there, it is extremely useful to see working VBA when trying to get better at it. Would you be able to tell me how to alter this code if I wanted to input the starting year as opposed to it automatically starting now (so I could start in 1923 for example?)

Thank you again for your help, I am just starting to get into VBA and this is a great resource.

JT
 
Upvote 0
Is there any easy way to do this if the goal is to able to input the starting year as opposed to having the default (current year)?
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top