VBA 2017年カレンダー作成




エクセル形式の2017年(2017年1月~12月)カレンダーです。
四半期は1月~3月を第1四半期としています。




コード
Sub calenddd()
Dim ws As Worksheet, i As Long
Dim firstDay As Date

'inputボックスに一日目を入力
firstDay = InputBox(Date, "最初の日", "YYYY/MM/DD")

Set ws = Worksheets(1)
    
With ws
 For i = 2 To 367 'めんどいので余分にとっておく
       
  If i <> 2 Then
   .Cells(i, 1) = Format(.Cells(i - 1, 1) + 1, "YYYY/MM/DD")
  Else
   .Cells(i, 1) = Format(firstDay, "YYYY/MM/DD")
  End If
     
    'スラッシュない形式
     .Cells(i, 2) = Format(.Cells(i, 1), "YYYYMMDD") 
    '曜日(略
     .Cells(i, 3) = Format(.Cells(i, 1), "aaa") 
    '曜日(フル
     .Cells(i, 4) = Format(.Cells(i, 1), "aaaa")
    'Yobi(Ryaku 
     .Cells(i, 5) = Format(.Cells(i, 1), "ddd") 
    'Yobi(Full
     .Cells(i, 6) = Format(.Cells(i, 1), "dddd")
    '和暦 
     .Cells(i, 7) = Format(.Cells(i, 1), "ggg") 
    '年月
     .Cells(i, 8) = Format(.Cells(i, 1), "YYYYMM") 
    '四半期
     .Cells(i, 9) = Format(.Cells(i, 1), "q") & "Q" 
    End If
 Next i
End With

End Sub



参照・類似ページ
日付表示書式指定(Format)関数
日付を取得する(Date)関数
年月日計算値(シリアル値)を取得する(DateSerial)関数