|
- Sub 插入空行()
- Dim arr, i As Integer, j As Integer
- Application.ScreenUpdating = False
- i = Cells(Rows.Count, 4).End(3).Row
- arr = Range("d4:d" & i)
- For j = i To 5 Step -1
- If arr(j - 4, 1) <> 1 Then
- Rows(j).Resize(arr(j - 4, 1) - 1).Insert
- End If
- Next j
- Application.ScreenUpdating = True
- Call tianc
- Call heb
- End Sub
- Sub heb()
- Dim y, mrg1 As Range
- Application.DisplayAlerts = False
- Set mrg1 = [d4]
- For y = 2 To Range("d65536").End(xlUp).Row + 1
- If Cells(y, 4) = Cells(y - 1, 4) Then
- Set mrg = Union(mrg, Cells(y, 4))
- Else
- mrg1.Merge
- Set mrg1 = Cells(y, 4)
- End If
- Next y
- Application.DisplayAlerts = True
-
- End Sub
- Sub tianc()
- Dim x As Integer
- Dim mrg As Range
- Set mrg = [d4]
- For x = 2 To Range("d65536").End(xlUp).Row - 1
- If Cells(x + 1, 4) = "" Then
- Set mrg = Cells(x, 4)
- Cells(x + 1, 4) = mrg
-
- Else
-
- Set mrg = Cells(x, 4)
- End If
- Next x
-
- End Sub
复制代码
|
|