View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
StargateFan[_3_] StargateFan[_3_] is offline
external usenet poster
 
Posts: 171
Default Formula to return last day of month for each month in year?

On Mon, 02 Jan 2006 16:07:13 -0500, Ron Rosenfeld
wrote:

On Mon, 02 Jan 2006 13:19:09 -0500, StargateFan
wrote:


[snip]

With just the year in A1, a formula that will give the last day of the month in
A2:A13

A2: =DATE($A$1,ROWS($A$2:A2)+1,0)

copy/drag across to B2 (or in B2 merely put =A2)

To display the dates the way you specify, you can use custom formatting:

Select A2, then Format/Cells/Numbers/Custom Type: mmmm - yyyy
Select B2, then Format/Cells/Numbers/Custom Type: ddd.mmm.dd.yyyy

Finally, select A2:B2 and copy/drag down to A13:B13

One difference from your specification: Formatting cannot give a result for
the day such as 'Tues'; it can only give a three letter day abbreviation 'Tue'
or the full day spelled out. If this is an issue, there is a solution, but it
would certainly be more cumbersome.

If you do not want to custom format the cells, you would have to turn the
results into a text string. Something like:

A2: =TEXT(DATE($A$1,ROWS($A$2:A2)+1,0),"mmmm-yyy")
B2: =TEXT(DATE($A$1,ROWS($A$2:B2)+1,0),"ddd.mmm.dd.yyy ")


This worked perfectly. (And, no, XL2K regular formatting just fine
<g.) Thanks! :oD