用VBA锁定和解锁
问题描述:
对我有一些代码,我使用VBA录音机编写,但我想在开始时添加解锁表单,然后在表尾锁定表单。用VBA锁定和解锁
私人小组CommandButton1_Click()
' ' New_Risk_4宏 ActiveSheet.UsedRange '重置最后一个有源单元'
Sheets("Risk Template").Select
'Looks at the risk template sheet'
ActiveCell.Rows("1:7").EntireRow.Select
ActiveCell.Offset(0, 4).Range("A1").Activate
'selects everything within the range'
Selection.Copy
'Copies to clipboard'
Sheets("Risk Input Sheet").Select
'Switches back to Risk Input sheet'
ActiveCell.SpecialCells(xlLastCell).Select
'Selects last active cell'
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
'Selects row with last active cell'
ActiveSheet.Paste
'Paste to select row'
答
完成它!
私人小组CommandButton1_Click()
ActiveSheet.Unprotect ' ' New_Risk_4宏 ActiveSheet.UsedRange '重置最后一个活动单元格'
Sheets("Risk Template").Select
'Looks at the risk template sheet'
ActiveCell.Rows("1:7").EntireRow.Select
ActiveCell.Offset(0, 4).Range("A1").Activate
'selects everything within the range'
Selection.Copy
'Copies to clipboard'
Sheets("Risk Input Sheet").Select
'Switches back to Risk Input sheet'
ActiveCell.SpecialCells(xlLastCell).Select
'Selects last active cell'
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
'Selects row with last active cell'
ActiveSheet.Paste
'Paste to select row'
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
末次
那么为什么不你只需添加它?你有什么问题? –
你的问题是什么? –
[VBA事件 - 解锁受保护工作表中的单元格,如果选中]的可能重复(http://*.com/questions/27332602/vba-event-unlock-cell-in-protected-sheets-if-selected) – DragonSamu