|
楼主 |
发表于 2024-1-14 19:43
|
显示全部楼层
本帖最后由 wzd028 于 2024-1-14 21:50 编辑
谢谢版主,可以用,现整理供各位参考
Sub 宏1()
Dim Arr, i&, Myr&, Shp As Shape, rng As Range
Dim d, k, n%
Set d = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
Sheet1.Activate
Myr = Cells(Rows.Count, 1).End(xlUp).Row
Arr = Range("a4:L" & Myr)
For Each Shp In Sheet1.Shapes
If Shp.Left > [h1].Left Then
d(Shp.TopLeftCell.Row) = ""
End If
Next
k = d.keys
For i = UBound(Arr) To 2 Step -1
If Not d.exists(Arr(i, 1) + 4) Then
n = n + 1
If n = 1 Then Set rng = Rows(Arr(i, 1) + 4) Else Set rng = Union(rng, Rows(Arr(i, 1) + 4))
End If
Next
If Not rng Is Nothing Then rng.Delete
Myr = Cells(Rows.Count, 1).End(xlUp).Row
Arr = Range("a4:L" & Myr)
For i = 2 To UBound(Arr)
Cells(i + 3, 1) = i - 1
Next
Application.ScreenUpdating = True
End Sub
|
|