这就是我想做的。我有五列(A、B、C、D、E)。我的要求是在每一行中,只有一个单元格应接受数据,其余单元格不应接受数据(即其余四个单元格应处于锁定模式)。
例如,如果用户在第 1 列中输入 1,BCDE 将被锁定,但如果用户决定更改选项,他们可以放回原始数据并更改为列中的另一个值。下面是我正在尝试做的一个示例。
VeryStrong Strong Neutral Weak VeryWeak
1 0 0 0 0 Data keyed by user 1
0 1 0 0 0 Data keyed by user 2
0 1 1 0 0 *This is what I am trying to prevent*
用户 1 可以返回并更改
Private Sub Worksheet_Change(ByVal Target As Range)
Me.Unprotect
If Not IsEmpty(Target) Then
'Data was added in target cell. Lock its neighbours.
Me.Cells(Target.Row, 1).Resize(, 5).Locked = True
Target.Locked = False
Else
'Data was erased from target cell. Release its neighbours.
Me.Cells(Target.Row, 1).Resize(, 5).Locked = False
End If
Me.Protect
End Sub