我试图让 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