練習問題12(日付関数の練習)) メモ
Sub Pra12()
Dim i As Long
Dim intW As Integer
Range("G2:I8").ClearContents
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
intW = Weekday(DateSerial(Cells(i, 1), Cells(i, 2), Cells(i, 3)), vbMonday)
Cells(intW + 1, 7) = Cells(intW + 1, 7) + Cells(i, 4)
Cells(intW + 1, 8) = Cells(intW + 1, 8) + 1
Next
For i = 1 To 7
Cells(i + 1, 9) = Cells(i + 1, 7) / Cells(i + 1, 8)
Next
End Sub
メモ:
*intW → 変数の名前
*ClearContents→ 数式と文字を削除する
*DateSerial→ (西暦, 月, 日付)
For i = 1 To 7
Cells(i+1,7) = Cells(i+1,7) / Cells(i+1,8)
→ 仮に月曜日だとすれば, Cells(月曜日の+ 平均 売上) = Cells(月曜日の+ 売上合計) / Cells(月曜日の+日数) と覚える