|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 插入行()
Application.ScreenUpdating = False
Dim rn As Range
With ActiveSheet
r = .Cells(Rows.Count, 5).End(xlUp).Row
Set rn = .Range("e9:e" & r).Find("合计:", , , , , , 1)
If rn Is Nothing Then MsgBox "找不到合计:字段!": End
rs = rn.Row
If r = rs Then
hs = 1
Else
hs = r - 10
End If
.Cells(rs, 5).Resize(hs, 5).Cut Destination:=.Range("E" & rs + 2).Resize(hs, 5)
.Range("K7:o8").Copy .Cells(rs, 5)
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
Sub 删除行()
Application.ScreenUpdating = False
Dim rn As Range
With ActiveSheet
r = .Cells(Rows.Count, 5).End(xlUp).Row
Set rn = .Range("e9:e" & r).Find("合计:", , , , , , 1)
If rn Is Nothing Then MsgBox "找不到合计:字段!": End
rs = rn.Row
If rs = 9 Then MsgBox "没有数据可删除!": Exit Sub
.Cells(rs - 1, 5).Resize(1, 5).Delete Shift:=xlShiftUp
End With
Application.ScreenUpdating = True
End Sub
|
|