- Sub 家庭成员合并()
- Dim d, ar, br(), m, i, j, s
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- ar = Range("A1").CurrentRegion
- For i = 4 To UBound(ar)
- If ar(i, 7) = "本人" Then
- s = ar(i, 2)
- If d(s) = "" Then
- m = m + 1: ReDim Preserve br(1 To 3, 1 To m)
- d(s) = m: br(1, m) = s: br(2, m) = i
- End If
- End If
- Next
- For i = 1 To UBound(br, 2) - 1: br(3, i) = br(2, i + 1) - 1: Next
- br(3, m) = UBound(ar): sa = Array(1, 4, 5, 6, 8)
- Application.DisplayAlerts = False
- For i = 1 To UBound(br, 2)
- For j = 0 To 4: Range(Cells(br(2, i), sa(j)), Cells(br(3, i), sa(j))).Merge: Next
- Next
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- Set d = Nothing
- End Sub
复制代码 |