|
Sub test2()
Dim A, B, i, t, x, y, z
A = [j2].CurrentRegion
ReDim B(1 To UBound(A) - 2, 1 To 1)
For i = 3 To UBound(A)
If Cells(i + 1, 12).End(xlToRight).Column <> Columns.Count Then
Set x = Range(Cells(i + 1, 12), Cells(i + 1, 41)).SpecialCells(2)
'遍历子区域
For Each y In x.Areas
'1)一个子区域
For Each z In y
If y.Count = 1 Then
t = Format(z, "m/d")
Else
t = Format(z, "m/d") & "~" & Format(z + y.Count - 1, "m/d")
End If
Exit For
Next
'2)连接子区域
B(i - 2, 1) = B(i - 2, 1) & "," & t
Next
B(i - 2, 1) = Mid(B(i - 2, 1), 2)
End If
Next i
Range("f:f").NumberFormat = "m/d"
[f4].Resize(UBound(B)) = B
End Sub
月度缺勤汇总2.rar
(15.32 KB, 下载次数: 3)
|
|