我試圖讓一個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