|
为什么会提示此错误呢?【参数数错误或无效的属性赋值(错误 450)】, 请VBA高手帮忙修正如下代码,万分感谢:
程序想要实现的功能:从第4行至65536行,通过改变H, I列值,而实现对本行E~G单元格的锁定并保护。
Private Sub Worksheet_Change(ByVal Target As Range) '不能被触发
'Application.EnableEvents = True
Dim x As Integer
For x = 4 To 65536 Step 1
If Target.Address = "$H$" & x And Target.Value <> "" Then
Range("E" & x, "F" & x, "G" & x).Locked = True
Protect "123456789"
MsgBox "此笔报销已被财务审核,不能再修改。请开新记录,重新登记。谢谢!"
If Target.Address = "$H$" & x And Target.Value = "" Then
Unprotect "123456789"
Range("E" & x, "F" & x, "G" & x).Locked = False
If Target.Address = "$I$" & x And Target.Value <> "" Then
Range("E" & x, "F" & x, "G" & x).Locked = True
Protect "123456789"
MsgBox "此笔报销已被财务审核,不能再修改。请开新记录,重新登记。谢谢!"
If Target.Address = "$I$" & x And Target.Value = "" Then
Unprotect "123456789"
Range("E" & x, "F" & x, "G" & x).Locked = False
Else
Unprotect "123456789"
Range("E" & x, "F" & x, "G" & x).Locked = False
End If
End If
End If
End If
Next x
End Sub
本帖最后由 zjdh 于 2012-10-30 20:02 编辑
Private Sub Worksheet_Change(ByVal Target As Range)
If (Target.Column = 8 Or Target.Column = 9) And Target.Count = 1 And Target.Row > 3 Then
Unprotect "123456789"
x = Target.Row
If Target.Value <> "" Then
Range("E" & x & ":G" & x).Locked = True
MsgBox "此笔报销已被财务审核,不能再修改。请开新记录,重新登记。谢谢!"
End If
For I = 4 To 5000
If Cells(I, 8) <> "" Or Cells(I, 9) <> "" Then
Range("E" & I & ":G" & I).Locked = True
Else
Range("E" & I & ":G" & I).Locked = False
End If
Next
Protect "123456789"
End If
End Sub
|
|