Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I need a piece of vba code to determine if it's a leap year. Then I can add 29 days for the month of february. Kind regards Jan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jan,
Here is one way, assuming your date is in A1 =IF(MONTH(DATE(YEAR(A1),2,29))=2,"Leap Year","Not a Leap Year") -- HTH RP (remove nothere from the email address if mailing direct) "Jan" wrote in message ... Hi all, I need a piece of vba code to determine if it's a leap year. Then I can add 29 days for the month of february. Kind regards Jan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jan,
But are you sure you need this? In General, Excel will take care of dates and the number of days in a month quite reliably. -- Kind Regards, Niek Otten Microsoft MVP - Excel "Bob Phillips" wrote in message ... Jan, Here is one way, assuming your date is in A1 =IF(MONTH(DATE(YEAR(A1),2,29))=2,"Leap Year","Not a Leap Year") -- HTH RP (remove nothere from the email address if mailing direct) "Jan" wrote in message ... Hi all, I need a piece of vba code to determine if it's a leap year. Then I can add 29 days for the month of february. Kind regards Jan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Unless of course, you start with a date in 1900 :-)
-- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ---------------------------------------------------------------------------- It's easier to beg forgiveness than ask permission :-) ---------------------------------------------------------------------------- "Bob Phillips" wrote in message ... Jan, Here is one way, assuming your date is in A1 =IF(MONTH(DATE(YEAR(A1),2,29))=2,"Leap Year","Not a Leap Year") -- HTH RP (remove nothere from the email address if mailing direct) "Jan" wrote in message ... Hi all, I need a piece of vba code to determine if it's a leap year. Then I can add 29 days for the month of february. Kind regards Jan |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Building on Bob's suggestion would be to determine the last day in February
(the zeroeth day in March) in VBA lyear = 2007 for i = 1 to day(dateSerial(lyear,3,0)) to demonstrate from the immediate window: ? day(dateserial(2008,3,0)) 29 -- Regards, Tom Ogilvy "Bob Phillips" wrote in message ... Jan, Here is one way, assuming your date is in A1 =IF(MONTH(DATE(YEAR(A1),2,29))=2,"Leap Year","Not a Leap Year") -- HTH RP (remove nothere from the email address if mailing direct) "Jan" wrote in message ... Hi all, I need a piece of vba code to determine if it's a leap year. Then I can add 29 days for the month of february. Kind regards Jan |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, this was where what i'm looking for.
Jan "Jan" wrote: Hi all, I need a piece of vba code to determine if it's a leap year. Then I can add 29 days for the month of february. Kind regards Jan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Leap Year | Excel Worksheet Functions | |||
leap year | Excel Discussion (Misc queries) | |||
Leap Year | Charts and Charting in Excel | |||
How to determine if year is a leap year | Excel Worksheet Functions | |||
Leap Year | Excel Programming |