我试图阻止输入特定值(文字说"最新"),但我所获得的代码似乎没有起作用,任何帮助将不胜感激,谢谢。
Private Sub RevisionInput()
Dim Revision As Range
Dim Revisioncell As Range
Set Revision = Range("M3:M500")
For Each Revisioncell In Revision
If Revisioncell Like "Latest" Or Revsioncell Like "LATEST" Or Revisioncell Like "latest" Then
MsgBox "Please input correct revision or if one is not available," & _
" Please type 'To be confirmed'"
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Else
End Sub
答案 0 :(得分:2)
您可以在没有VBA的情况下执行此操作。在功能区上的“数据”选项卡下选择“数据验证”,然后从下拉列表中选择自定义并将公式设置为(将M3
替换为所选内容中的第一个单元格):
=M3<>"latest"