|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 排班表样式()
Dim d As Object
Dim arr()
Set d = CreateObject("scripting.dictionary")
T = Timer
With Sheets("全年排班")
ks = .[b1]
js = .[d1]
If ks = "" Then MsgBox "请先输入开始日期!": Exit Sub
If js = "" Then MsgBox "请先输入结束日期!": Exit Sub
If Not IsDate(ks) Then MsgBox "请先输入标准开始日期!": Exit Sub
If Not IsDate(js) Then MsgBox "请先输入标准结束日期!": Exit Sub
ts = DateDiff("d", ks, js)
ReDim arr(1 To ts + 1, 1 To 2)
r = Cells(Rows.Count, 1).End(xlUp).Row
.Range("a3:f" & r + 1).Borders.LineStyle = 0
.Range("a3:f" & r + 1).Interior.ColorIndex = 0
.Range("a3:f" & r + 1) = Empty
rr = Array(1, "一", 2, "二", 3, "三", 4, "四", 5, "五", 6, "六", 7, "日")
For i = 0 To UBound(rr) Step 2
d(rr(i)) = rr(i + 1)
Next i
For i = 0 To ts
n = n + 1
arr(n, 1) = ks + 1
xq = Weekday(ks + i, 2)
arr(n, 2) = "星期" & d(xq)
If xq = 6 Or xq = 7 Then Range("a" & n + 2 & ":f" & n + 2).Interior.ColorIndex = 50
Next i
.[a3].Resize(n, 2) = arr
.Range("a3:f" & ts + 3).Borders.LineStyle = 1
End With
MsgBox "耗时:" & Format(Timer - T, "0.00") & "秒"
Set d = Nothing
End Sub
|
|