|
▼りお さん:
こんにちは。
出かける直前にあせって投稿したので、訂正です。
>標準モジュールに
>'=============================================================
>Sub main()
> Dim st As Long
> Dim stm As Long
> Dim edm As Long
> Dim idx As Long
> Dim lim As Long
> st = Range("a2")
> stm = Range("b2").Value
> edm = Range("c2").Value
> idx = st
> Dim myarray(1 To 9) As Variant
> lim = UBound(myarray())
> Do Until Month(DateSerial(Year(Date), stm, 1)) = edm Or idx = st + lim
> myarray(IIf(idx Mod lim = 0, lim, idx Mod lim)) = DateSerial(Year(Date), stm, 1)
> idx = idx + 1
> stm = stm + 1
> Loop
> If Month(DateSerial(Year(Date), stm, 1)) = edm Then
> myarray(IIf(idx Mod lim = 0, lim, idx Mod lim)) = DateSerial(Year(Date), stm, 1)
> End If
> With Range("a1:i1")
> .Value = myarray()
> .NumberFormatLocal = "m""月"""
> End With
>End Sub
を
'==============================================================
Sub main()
Dim st As Long
Dim stm As Long
Dim edm As Long
Dim idx As Long
Dim lim As Long
st = Range("a2")
stm = Range("b2").Value - 1
edm = Range("c2").Value
idx = st
Dim myarray(1 To 9) As Variant
lim = UBound(myarray())
Do
stm = stm + 1
myarray(IIf(idx Mod lim = 0, lim, idx Mod lim)) = _
DateSerial(Year(Date), stm, 1)
idx = idx + 1
Loop Until Month(DateSerial(Year(Date), stm, 1)) = edm _
Or idx = st + lim
With Range("a1:i1")
.Value = myarray()
.NumberFormatLocal = "m""月"""
End With
End Sub
とすると、ちょっとだけすっきりしました。
コードの仕様は同じです。
確認してください。
|
|