|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Dim v As Variant
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If (Target.Column = 5 Or Target.Column = 7) And Target.Row >= 3 Then '范围
v = Target '提取未更改前的数据
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Long
If Target.Column = 7 And Target.Row >= 3 Then '孔数锁定
r = Target.Row
If Cells(r, 6) = 1 Then '第六列,进程
Application.EnableEvents = False '不激活事件
Target = v '还原数据
Target.Select
Application.EnableEvents = True
MsgBox "此单元格内容已锁定!", vbInformation, "提示"
End If
ElseIf Target.Column = 5 And Target.Row >= 3 Then '进尺锁定
r = Target.Row
If Cells(r, 6) = 2 Then '第六列,进程
Application.EnableEvents = False '不激活事件
Target = v '还原数据
Target.Select
Application.EnableEvents = True
MsgBox "此单元格内容已锁定!", vbInformation, "提示"
End If
End If
End Sub |
|