编写宏
Sub 增加一行()
'
' 增加一行 Macro
' 宏由 zbf 录制,时间: 2010-12-20
a = Cells(1, 5).Value '指定一个单元格保存该区域的最后一行行号,目的是为了插入最后一行
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="123" ' 设置密码
Rows(a).Select '选择指定行
Selection.Copy '复制该行
Selection.Insert Shift:=xlDown '插入复制的行
a = a + 1
Cells(a, 1) = ""
Cells(a, 2) = ""
Cells(a, 3) = ""
Cells(a, 5) = ""
Cells(a, 6) = ""
Cells(a, 4).Locked = True
Cells(a, 4).FormulaHidden = True '以上是对不要的单元格设置空,需要保护的单元格锁定,隐藏
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
Application.ScreenUpdating = True '以上是允许插入,修改等
ActiveSheet.Protect Password:="123" '设置密码
Cells(1, 5).Value = a '保留最后一行行号
End Sub
最后在表格中加一个按钮,该按钮指定到该宏中,就OK了来自:求助得到的回答
温馨提示:答案为网友推荐,仅供参考