软件版本:Office2007
举例说明如下:
1.将底色为黄色的范围内的内容删除:
2.Alt+F11,输入代码如下:
Range("B3:C7").ClearContents '将区域B3:C7内容清空
3.F5执行代码,关闭VBE,返回Excel得到结果如下:
Sub s()
Dim rg As Range, c As Range
Set rg = [a39:j1039]
t1 = [l30]
t2 = [o32]
ca = Array(1, 4)
cb = Array(2, 3)
For Each c In rg
s1 = (Val(Mid(c, ca(0), 1)) + Val(Mid(c, ca(1), 1))) Mod 10
s2 = (Val(Mid(c, cb(0), 1)) + Val(Mid(c, cb(1), 1))) Mod 10
If InStr(t1, s1) > 0 And InStr(t2, s2) > 0 Then c = ""
Next
End Sub