|
- Sub Dec3rd()
- Dim ar, br() As String
- Dim i As Integer, j As Integer, k As Integer
- ar = Range("S1", Cells(Rows.Count, "P").End(xlUp))
- ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
- br(1, 3) = ar(1, 1)
- br(1, 4) = ar(1, 4)
- For i = 2 To UBound(ar)
- If ar(i, 2) = "户主" Then j = 1 Else If j = 1 Then br(i, 1) = "与户主关系": j = 2
- br(i, j) = ar(i, 2)
- br(i, 3) = ar(i, 1)
- br(i, 4) = ar(i, 4)
- Next
- With Range("D1")
- .CurrentRegion.Clear
- With .Resize(UBound(br), UBound(br, 2))
- .Value = br
- .Borders.LineStyle = xlContinuous
- .HorizontalAlignment = xlCenter
- End With
- For i = UBound(br) To 2 Step -1
- k = k + 1
- If br(i, 1) = "户主" Then
- k = k - 1
- If k > 1 Then .Offset(i).Resize(k).Merge
- .Offset(i - 1).Resize(, 2).HorizontalAlignment = 7
- k = 0
- End If
- Next
- End With
- Beep
- End Sub
复制代码 |
|