我试图让一个OR循环工作在VBA中,而不是避免单元格中有字母,它使整个数组“ - ”。即使我输入数字或单词,它也会用短划线代替整个数组。或循环做我想要的相反
Private Sub CommandButton1_Click()
Dim l As Double, c As Double
For l = 14 To 18
For c = 10 To 12
If Cells(l, c).Value <> "W" Or _
Cells(l, c).Value <> "w" Or _
Cells(l, c).Value <> "X" Or _
Cells(l, c).Value <> "x" Or _
Cells(l, c).Value <> "Y" Or _
Cells(l, c).Value <> "y" Or _
Cells(l, c).Value <> "Z" Or _
Cells(l, c).Value <> "z" Then
Cells(l, c).Value = "-"
End If
Next c
Next l
End Sub
您的意思是使用和? – tangrs
查询“德摩根法则”。 (这里是维基百科的文章,尽管它有点不透明:http://en.wikipedia.org/wiki/De_Morgan's_laws) – RBarryYoung