如何在Excel中使用索引搜索锁定/解锁单元格

时间:2017-02-23 02:14:25

标签: excel vba locking cell

我希望在使用index-match公式匹配条件时解锁单元格。

我尝试了很多,但它没有用。你能告诉我我的错误吗?

Private Sub Worksheet_ChangeS(ByVal Target As Range)
  If[X9] > "42401" Then
      ActiveSheet.Unprotect("pswrd")[ = INDEX(A16: L35, MATCH(X9, A16: A35, 0), MATCH("GPF", A16: L16, 0))].Locked = False
      ActiveSheet.Protect("pswrd")
  Else
      ActiveSheet.Unprotect("pswrd")[ = INDEX(A16: L35, MATCH(X9, A16: A35, 0), MATCH("GPF", A16: L16, 0))].Locked = True
      ActiveSheet.Protect("pswrd")
  End If
End Sub

0 个答案:

没有答案