|
Sub s()
Dim i As Long, y As Long, k As Long, m As Long, n As Long
With Sheet1
n = .Range("A65536").End(xlUp).Row / 4 * 8
For i = 1 To n Step 8
If .Cells(i, 1) <> "" Then
If .Cells(i, 1).End(xlDown).Row < 8 + i Then
y = 8 - (.Cells(i, 1).End(xlDown).Row - i)
Rows(.Cells(i, 1).End(xlDown).Row).EntireRow.Resize(y).Insert
For k = 1 To 4
.Range(Cells(i, k), Cells(.Cells(i, 1).End(xlDown).Row - 1, k)).MergeCells = True
Next
End If
End If
Next
n = .Range("A65536").End(xlUp).Row
For k = 1 To 4
.Range(Cells(n, k), Cells(n + 8, k)).MergeCells = True
Next
.Range(Cells(n, 1), Cells(n + 8, 8)).Borders.LineStyle = 1 '加入边框
End With
End Sub |
|