Formula for selecting a Leap Year.

B

BadBoy

Hello,

The first formula below checks to see if the word February is in one cell
and the year 2012 in another and if so, will place the number 29 in another
cell for me and if not, 28.

=IF(AND('Monthly Totals'!L8="February",'Monthly Totals'!O8=2012),29,28)

I am looking to create a formula that will look for the word February in one
cell and one these following years. Not just 2012.
2012, 2016, 2020, 2024, 2028

If February has been selected from a drop window and as well, one of those
years from another drop window, I wish the program to know that someone has
selected a leap year and will place the date number 29 in a cell. Otherwise,
the number 28.

This formula works well but it only checks for the year 2012.
=IF(AND('Monthly Totals'!L8="February",'Monthly Totals'!O8=2012),29,28)

This formula does not work.
=IF(AND('Monthly Totals'!L8="February",'Monthly
Totals'!O8={2012,2016,2020,2024,2028}),29,28)

Thank you in advance for any help you may have to offer.

-Bad
 
B

BadBoy

Thank you Glen,

This code is just about perfect.

All I need now is to have the day stay at 29 if January or any other month
other than Feb is selected.

=IF('Monthly Totals'!L8="February",DAY(DATE('Monthly Totals'!O8,3,0)))

-Bad
 
B

BadBoy

The sheets are named 1 through 31.

If February is selected as the month, I have this formula on the 30th and
31st.
{=IF('Monthly Totals'!L8="February",0,30)}

As for the 31st on a month other than February, I haddn't thought about
that. (ha ha)

Suggestions?

Thank you

-Bad

Glenn said:
If your sheets are named 1, 2, 3, 4, etc. then the following will work on all
sheets:

=IF(DAY(DATE('Monthly Total'!O8,MONTH(DATEVALUE("1-"&'Monthly Total'!L8&
"-2000"))+1,0))>=--MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99),
--MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99),"")

How are your daily sheets named?

How do you deal with 30 in February and 31 in February, April, June,
September and November?
 
G

Glenn

Glenn said:
=IF('Monthly Totals'!L8="February",DAY(DATE('Monthly Totals'!O8,3,0)))

Forgot the "false" portion of the formula...not sure what you want there:

=IF('Monthly Totals'!L8="February",DAY(DATE('Monthly Totals'!O8,3,0)),"Not
February")
 
G

Glenn

How are your daily sheets named?

How do you deal with 30 in February and 31 in February, April, June, September
and November?
 
G

Glenn

If your sheets are named 1, 2, 3, 4, etc. then the following will work on all
sheets:

=IF(DAY(DATE('Monthly Total'!O8,MONTH(DATEVALUE("1-"&'Monthly Total'!L8&
"-2000"))+1,0))>=--MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99),
--MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99),"")
 
G

Glenn

Suggestion below.
The sheets are named 1 through 31.

If February is selected as the month, I have this formula on the 30th and
31st.
{=IF('Monthly Totals'!L8="February",0,30)}

As for the 31st on a month other than February, I haddn't thought about
that. (ha ha)

Suggestions?

Thank you

-Bad

Glenn said:
If your sheets are named 1, 2, 3, 4, etc. then the following will work on all
sheets:

=IF(DAY(DATE('Monthly Total'!O8,MONTH(DATEVALUE("1-"&'Monthly Total'!L8&
"-2000"))+1,0))>=--MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99),
--MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99),"")

How are your daily sheets named?

How do you deal with 30 in February and 31 in February, April, June,
September and November?


BadBoy wrote:
Thank you Glen,

This code is just about perfect.

All I need now is to have the day stay at 29 if January or any other
month other than Feb is selected.

=IF('Monthly Totals'!L8="February",DAY(DATE('Monthly Totals'!O8,3,0)))

-Bad

:

BadBoy wrote:
Hello,

The first formula below checks to see if the word February is in one
cell and the year 2012 in another and if so, will place the number
29 in another cell for me and if not, 28.

=IF(AND('Monthly Totals'!L8="February",'Monthly Totals'!O8=2012),29,28)

I am looking to create a formula that will look for the word
February in one cell and one these following years. Not just 2012.
2012, 2016, 2020, 2024, 2028

If February has been selected from a drop window and as well, one of
those years from another drop window, I wish the program to know
that someone has selected a leap year and will place the date number
29 in a cell. Otherwise, the number 28.

This formula works well but it only checks for the year 2012.
=IF(AND('Monthly Totals'!L8="February",'Monthly Totals'!O8=2012),29,28)

This formula does not work.
=IF(AND('Monthly Totals'!L8="February",'Monthly
Totals'!O8={2012,2016,2020,2024,2028}),29,28)

Thank you in advance for any help you may have to offer.

-Bad
=IF('Monthly Totals'!L8="February",DAY(DATE('Monthly Totals'!O8,3,0)))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top