LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to Show 12 months dates on the basis of from today's date

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.




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
show the date when it is later than today's date Aline Excel Worksheet Functions 4 November 25th 08 10:16 PM
Macro to locate today's date from a list of dates DOOGIE Excel Programming 1 April 18th 07 08:52 PM
sum of 2 Months basis Andri Excel Worksheet Functions 1 March 26th 07 03:24 AM
how do I put today's date and other dates in macro condition? lpdarspe Excel Programming 4 April 5th 06 01:21 AM
Are 2 dates between today's date Pivot Table/Query Excel Programming 1 September 8th 05 09:43 PM


All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"