View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H[_3_] Mike H[_3_] is offline
external usenet poster
 
Posts: 39
Default Generate calendar column month headers in YYMM Format

Hi,

Right click your sheet tab, view code and paste the code below in and
run it. It picks up startdate and enddate from a1 and B1 respectively

Sub FillCalendar()
Dim startdate As Date, enddate As Date
startdate = Range("A1").Value
enddate = Range("B1").Value
x = 1
Do
With Cells(2, x)
.Value = startdate
.NumberFormat = "mmyy"
End With
startdate = DateAdd("m", 1, startdate)
x = x + 1
Loop Until startdate enddate
End Sub

Mike

On Dec 26, 9:25*am, u473 wrote:
From the given First Month and Last Month dates, for instance
11/15/2008 and 03/20/2009,
*how do I loop and generate with VBA the columns headers of *0811,
0812, 0901, 0902, 0903.
Thank you for your help.
J.P.