在Checked列中根据“Y”值dynamic保护一行中的单元格?

如果我的用户将Y(是)input到特定行的列中,那么我需要保护特定行中的所有单元格,这表示用户已经检查了数据并且是正确的。 我一直无法弄清楚如何做到这一点。 有谁知道如何做到这一点? 非常感谢,Elias

根据你的要求和拜伦的评论,我编辑了代码。 代码应该被粘贴到工作表模块中

 Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False On Error GoTo Exiter Set Sh = Target.Parent If Target.Value = "Y" And Target.Column = 1 Then Unprotect Password:="WHATEVER" For Each curRow In Sh.UsedRange.Rows If Sh.Cells(curRow.Row, 1) = "Y" Then Sh.Cells(curRow.Row, 1).EntireRow.Locked = True Else Sh.Cells(curRow.Row, 1).EntireRow.Locked = False End If Next Sh.Protect Password:="WHATEVER" End If Exiter: Application.EnableEvents = True End Sub