|
6ヶ月間のカレンダーを作る、ということですか ?
ならばこんな感じで、どうでしょーか ? シートモジュールに入れて下さい。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim GtDy As Date, SDy As Date, EDy As Date
Dim i As Integer
With Target
If .Address <> "$A$1" Then Exit Sub
If .Count > 1 Then Exit Sub
If IsEmpty(.Value) Then Exit Sub
If Not IsDate(.Value) Then Exit Sub
GtDy = .Value
End With
Application.EnableEvents = False
Range("A2:F32").Clear
SDy = DateSerial(Year(GtDy), Month(GtDy), 1)
For i = 1 To 6
EDy = DateAdd("m", 1, SDy) - 1
With Cells(2, i)
.Value = SDy
.DataSeries xlColumns, xlChronological, _
xlDay, 1, EDy
End With
SDy = EDy + 1
Next i
Range("A:F").EntireColumn.AutoFit
Application.EnableEvents = True
End Sub
|
|