|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
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 |
|