如果它们包含6个文本字符串中的任何一个,我试图清除指定范围内任何单元格的内容。这是我到目前为止所用的,但它似乎不起作用,如果我只为它做一个字符串。
For Each cell In rng1
If cell.Value = "time" And "$ActiveCalibrationPage" And "$CalibrationLog" And "$EVENT_COMMENTS" And "$PAUSE_COMMENTS" And "$SNAPSHOT" Then
cell.ClearContents
End If
Next cell
有人可以指出我正确的方向吗
答案 0 :(得分:0)
使用Replace
样本范围A1:100
Sub OrAnd()
Dim vArr
Dim vArrE
Dim rng1 As Range
Set rng1 = [a1:a100]
vArr = Array("time", "$ActiveCalibrationPage", "$CalibrationLog", "$EVENT_COMMENTS", "$PAUSE_COMMENTS", "$SNAPSHOT")
For Each vArrE In vArr
rng1.Replace vArrE, vbNullString, xlWhole
Next
End Sub