You are here:

Advertisement

Seeking function:

I've created the following cells on an Excel spreadsheet

A1:=IF(OR(MONTH(NOW())=1,MONTH(NOW())=2,MONTH(NOW())=3),"January", IF(OR(MONTH(NOW())=4,MONTH(NOW())=5,MONTH(NOW())=6),"April",IF(OR(MONTH(NOW())=7,MONTH(NOW())=8,MONTH(NOW())=9),"June","September")))

A7:=IF(OR(MONTH(NOW())=1,MONTH(NOW())=2,MONTH(NOW())=3),"Feburary",IF(OR(MONTH(NOW())=4,MONTH(NOW())=5,MONTH(NOW())=6),"May",IF(OR(MONTH(NOW())=7,MONTH(NOW())=8,MONTH(NOW())=9),"July","October")))

A14:=IF(OR(MONTH(NOW())=1,MONTH(NOW())=2,MONTH(NOW())=3),"March", IF(OR(MONTH(NOW())=4,MONTH(NOW())=5,MONTH(NOW())=6),"June",IF(OR(MONTH(NOW())=7,MONTH(NOW())=8,MONTH(NOW())=9),"August","December")))

Is there a simpler way to have done the above formula?

Can you help me figure out how to get cells in column 'B' to display the correct Sundays for the correct month range for the current (NOW) year?

I.E. If A1 displays January then B1 displays first Sunday of January for current year and if A1 displays April then B1 displays first Sunday of April for current year.

Is there a way to have a row added to display a 5th week Sunday that would autohide when there is no 5th week Sunday for the given month for the current year?

Thank you for your help!

Daniel

=if(month(now())<=3,"January",if(Month(now())<=6,"April",if(month(now())<=9,"June","September")))

Another way you could do it is

=TEXT(DATE(YEAR(NOW()),((TRUNC((MONTH(NOW())-1)/3)+1)-1)*3+1,1),"MMMM")

Where it says *3+1 you would change +1 to +2 to get the second month in the quarter and +3 to get the third month in the quarter

=DATEVALUE(A1&" 1, "&YEAR(NOW()))+7-WEEKDAY(DATEVALUE(A1&" 1, "&YEAR(NOW()))-1,1)

will give you the date of the first sunday of the month listed in A1

=Date(YEAR(NOW()),A1,1+((1-(1>=WEEKDAY(DATE(YEAR(NOW()),A1,1))))*7)+(1-WEEKDAY(DATE(YEAR(NOW()),A1,1))))

this will give you the date of the 5th sunday in the month. You can compare the month of this date to the month you are checking. If they are the same, then you know this month has a 5th Sunday. If the month doesn't match, then the month in question does not have a fifth sunday.

=DATE(YEAR(NOW()),A1,1+((5-(1>=WEEKDAY(DATE(YEAR(NOW()),A1,1))))*7)+(1-WEEKDAY(DATE(YEAR(NOW()),A1,1))))

[Note: In A1 it is expecting a month number. If A1 contains a month name you can get a month number by replacing A1 with MONTH(DATEVALUE(A1&" 1, "&YEAR(NOW()))). So you would replace the A1 in each instance above with that formula. ]

However, a formula can not hide a row. You could put his formula someplace to return a value you can test that indicated whether the row should be used or not.

=normal formula would become

=if(indicator cell = True,normal formula,"")

Thus the cell would appear blank when it is not needed.

also, you might check out this site:

http://www.cpearson.com/Excel/DateFunctions1.aspx

the last formula is basically his.

--

Regards,

Tom Ogilvy

- Add to this Answer
- Ask a Question

Rating(1-10) | Knowledgeability = 10 | Clarity of Response = 10 | Politeness = 10 |

Comment | I really appreciate how helpful he is! He also is able to get my questions answers so quickly too! |

This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

Answers by Expert:

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Extensive experience. **Education/Credentials**

Master of Science (MS) degree Operations Research (ORSA)**Awards and Honors**

Microsoft MVP in Excel.