【发布时间】:2019-11-27 22:38:08
【问题描述】:
我有一个年份列表(例如 2016、2017、2018、2019、2020、2021...)
如何列出 2020 年的所有日子?
所以我会: .Cells(2, 2) = 01/01/2020.... 等到 2020 年 12 月 31 日显然在同一行
这就是我的代码的样子,但我认为我让它只适用于当年,例如。 2019
Dim MyMounth As Long
Dim MounthDays As Long
Dim MounthDays2 As Long
Dim MounthDaysAppoggio As Long
Dim riga As Long
Dim numeri As Long
Dim mese As Long
MounthDaysAppoggio = 1
MounthDays = Day(DateSerial(Year(Date), MounthDaysAppoggio + 1, 1) - 1)
mese = 1
riga = 2
numeri = 1
MounthDays2 = 0
For q = 1 To 12
For Row = 2 To MounthDays + 1
MounthDays2 = MounthDays2 + 1
Cells(4, riga).NumberFormat = 0
Cells(4, riga).Value = MounthDays2
Cells(4, riga).VerticalAlignment = xlCenter
Cells(4, riga).HorizontalAlignment = xlCenter
Cells(4, riga).BorderAround ColorIndex:=1, Weight:=xlMedium
riga = riga + 1
Next Row
MounthDays = Day(DateSerial(Year(Date), MounthDaysAppoggio + 1, 1) - 1)
MounthDays2 = 0
Next q
【问题讨论】: