|
こんなのでは
Option Explicit
Sub 曜日取得と一覧_2()
Dim f As Long
Dim myY As Variant
Dim myD As Long
Dim myL As Long
Dim lngRowM As Long
Dim lngRowF As Long
myY = Range("A1").Value
myD = DateSerial(Year(myY), Month(myY), 1)
myL = DateSerial(Year(myY), Month(myY) + 1, 0)
MsgBox Format(myD, "yyyy/m/d")
MsgBox Format(myL, "yyyy/m/d")
lngRowM = 3
lngRowF = 3
For f = myD To myL '←…ここで止まります。
'月曜日なら
If Weekday(f) = 2 Then
Cells(lngRowM, "A").Value = Format(f, "yyyy/m/d")
lngRowM = lngRowM + 1
End If
'金曜日なら
If Weekday(f) = 6 Then
Cells(lngRowF, "B").Value = Format(f, "yyyy/m/d")
lngRowF = lngRowF + 1
End If
Next f
End Sub
|
|