如果找到匹配项,则将“单元格”属性更改为“无填充” | VBA | Excel |

时间:2019-05-24 11:42:58

标签: excel vba

如果找到匹配的“ SUP”和“ AL”,我想删除行范围1:6和列范围A:AE中的单元格内容

范围是黄色的供参考,请看下图

Sample Image

1 个答案:

答案 0 :(得分:3)

有点困惑,但这是你的意思吗?

Sub FindReplaceAll()

Application.ReplaceFormat.Interior.Pattern = xlNone

With ActiveWorkbook.Sheets(1).Range("A1:AE6")
    .Cells.Replace what:=UCase("SUP"), Replacement:="", ReplaceFormat:=True
    .Cells.Replace what:=UCase("SUP"), Replacement:="", ReplaceFormat:=False
    .Cells.Replace what:=UCase("AL"), Replacement:="", ReplaceFormat:=True
    .Cells.Replace what:=UCase("AL"), Replacement:="", ReplaceFormat:=False
End With

End Sub

如果需要,您也可以申请LookAt:=xlPartLookAt:=xlWhole