Sub duplicateWorksheetByDate()
Dim ws As Worksheet
Dim firstSheet As Worksheet
Dim endDate As Date
Dim di As Date
Dim wd As Integer
Dim valuationDate As Date
endDate = "11/01/2021"
Set firstSheet = worksheets.Item(1)
Set ws = worksheets.Item(worksheets.Count)
For di = "10/20/2021" To endDate
wd = Weekday(di)
If wd <> 1 And wd <> 7 Then
firstSheet.Copy After:=ws
Set ws = worksheets.Item(worksheets.Count)
ws.Name = Format(di, "dd mmm yyyy")
If wd = 2 Then
valuationDate = DateAdd("D", -3, di)
Else
valuationDate = DateAdd("D", -1, di)
End If
ws.Cells(2, 4).Value = valuationDate
ws.Cells(3, 4).Value = valuationDate
End If
Next di
End Sub
VBA按日期创建sheet
最新推荐文章于 2024-07-11 14:58:58 发布