從當月的20日到下個月的19日創建表。爲什麼不會運行下面的代碼?從本月的特定日期到下個月的特定日期創建Excel VBA表
Dim sDate As Date, nDate As Date
sDate = DateSerial(Year(Date), Month(Date), 20)
nDate = DateSerial(Year(Date), Month(Date) + 1, 19)
For k = sDate To nDate 'DaysInMonth
'copy template sheet
wbkCur.Worksheets("Template").Copy After:=Sheets(wbkCur.Worksheets.Count)
Select Case k
Case 1, 21, 31
TabName = "st"
Case 2, 22
TabName = "nd"
Case 3, 23
TabName = "rd"
Case Else
TabName = "th"
End Select
'rename to Day of Month
ActiveSheet.Name = ShortName & " " & k & TabName
next k
你試過跟蹤錯誤?你得到了什麼? –