Sorry, I forgot which newsgroup I was answering the question in. Give this a
try...
Sub InsertDates()
Dim X As Long
Const StartCell As String = "A1"
For X = 0 To 11
Range(StartCell).Offset(X).Value = DateSerial(Year(Now) - _
1, Month(Now) + X, 1)
Range(StartCell).Offset(X).NumberFormat = "mmm-yy"
Next
End Sub
--
Rick (MVP - Excel)
"arun" wrote in message
...
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.