- 帖子
- 976
- 主題
- 7
- 精華
- 0
- 積分
- 1018
- 點名
- 0
- 作業系統
- Win10
- 軟體版本
- Office 2016
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2013-4-19
- 最後登錄
- 2026-5-26
|
回復 1# 星空乂羽翼
請測試看看,謝謝
Sub test()
Dim Arr, xD, C%, T%, T1%
Application.DisplayAlerts = False
Set xD = CreateObject("Scripting.Dictionary")
C = Cells(5, Columns.Count).End(xlToLeft).Column
Arr = Range([e5], Cells(5, C))
For j = 1 To UBound(Arr, 2)
T = Month(Arr(1, j))
T1 = Split(Arr(1, j), "/")(2)
If T1 = 1 Then
If T = 1 Then
Cells(4, j + 4) = "一月"
ElseIf T = 2 Then
Cells(4, j + 4) = "二月"
ElseIf T = 3 Then
Cells(4, j + 4) = "三月"
ElseIf T = 4 Then
Cells(4, j + 4) = "四月"
ElseIf T = 5 Then
Cells(4, j + 4) = "五月"
ElseIf T = 6 Then
Cells(4, j + 4) = "六月"
ElseIf T = 7 Then
Cells(4, j + 4) = "七月"
ElseIf T = 8 Then
Cells(4, j + 4) = "八月"
ElseIf T = 9 Then
Cells(4, j + 4) = "九月"
ElseIf T = 10 Then
Cells(4, j + 4) = "十月"
ElseIf T = 11 Then
Cells(4, j + 4) = "十一月"
ElseIf T = 12 Then
Cells(4, j + 4) = "十二月"
End If
End If
If xD.Exists(T) Then
Set xD(T) = Union(xD(T), Cells(4, j + 4))
Else
Set xD(T) = Cells(4, j + 4)
End If
Next
For Each ky In xD.keys
xD(ky).Merge
Next
Application.DisplayAlerts = True
End Sub |
|