View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default How to Show 12 months dates on the basis of from today's date

this is what i came up with (probably can be done differently), but i
didn't know how you wanted to implement it.

'=============================
Option Explicit

Sub mydate()

Dim Ws As Worksheet
Dim c As Range

Set Ws = ActiveWorkbook.Worksheets("Sheet1")
Set c = Ws.Range("a1")

c.Value = Date - 365
c.Offset(1, 0).Value = Date - 335
c.Offset(2, 0).Value = Date - 305
c.Offset(3, 0).Value = Date - 275
c.Offset(4, 0).Value = Date - 245
c.Offset(5, 0).Value = Date - 215
c.Offset(6, 0).Value = Date - 185
c.Offset(7, 0).Value = Date - 155
c.Offset(8, 0).Value = Date - 125
c.Offset(9, 0).Value = Date - 95
c.Offset(10, 0).Value = Date - 65
c.Offset(11, 0).Value = Date - 30
c.Offset(12, 0).Value = Date

End Sub
'============================

the actual numbers might have to be adjusted somewhat. i just removed
30 from each larger date.
hope it helps
:)
susan



On Aug 12, 10:44*am, arun wrote:
Hi Rick,

I wanted *VB macro code for this, as i am doing other things also through
macro.



"Rick Rothstein" wrote:
Put this formula in A1 (or whatever cell you want) and copy it down...


=DATE(YEAR(TODAY())-1,MONTH(TODAY())+ROW(A1)-1,1)


then Custom Format those cells using this pattern...


mmm-yy


--
Rick (MVP - Excel)


"arun" wrote in message
...
Hi All,


I wanted to show 12 month dates.


The condition is that, the starting years should show one less i.e 2008
and
after jan the year should show the current year.
the column should look like this


'A1'-Aug-08
'A2'-Sep-08
'A3'-Oct-08
'A4'-Nov-08
'A5'-Dec-08
'A6'-Jan-09
--
--
'A12'-jul-09


the date should be based on current date.


I tried many ways, but not able to do this.- Hide quoted text -


- Show quoted text -