Sub 合併()
Dim R&, xR As Range, T1$, T2$, TC$, xH As Range, K
R = [D65536].End(xlUp).Row
With Range("A12:M" & R)
.UnMerge
.Borders.LineStyle = xlNone
End With
Application.DisplayAlerts = False
For Each xR In Range("A12:A" & R)
T1 = Split(xR(1, 4) & "-", "-")(0)
If T1 <> TC Then TC = T1: Set xH = xR
T2 = Split(xR(2, 4) & "-", "-")(0)
If T2 <> TC Then
For Each K In Array(1, 2, 3, 13)
Range(xR(1, K), xH(1, K)).Merge
Next K
End If
Next
Range("A12:M" & R).Borders.LineStyle = 1
End Sub作者: s13030029 時間: 2020-6-9 08:14