|
Sub 清除()
Dim rng As Range
For Each rng In Range("a1:b200") 'range("a1:b200")区域可以自己设定
If rng.Column > 1 And rng.Row > 1 Then
If rng Like "*大*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(-1, 0).ClearContents
rng.Offset(0, -1).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*中*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(-1, 0).ClearContents
rng.Offset(0, -1).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*小*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(-1, 0).ClearContents
rng.Offset(0, -1).ClearContents
rng.Offset(0, 1).ClearContents
End If
ElseIf rng.Column = 1 And rng.Row = 1 Then
If rng Like "*大*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*中*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*小*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(0, 1).ClearContents
End If
ElseIf rng.Column = 1 And rng.Row > 1 Then
If rng Like "*大*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(-1, 0).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*中*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(-1, 0).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*小*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(-1, 0).ClearContents
rng.Offset(0, 1).ClearContents
End If
ElseIf rng.Column > 1 And rng.Row = 1 Then
If rng Like "*大*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(0, -1).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*中*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(0, -1).ClearContents
rng.Offset(0, 1).ClearContents
ElseIf rng Like "*小*" Then
rng.ClearContents
rng.Offset(1, 0).ClearContents
rng.Offset(0, -1).ClearContents
rng.Offset(0, 1).ClearContents
End If
End If
Next
End Sub |
|