VBA - 在具有多个条件的范围内查找颜色字段

VBA -find in range with multiple conditions to color field

我一直在尝试创建一个 vba 代码来检查在所选单元格的每个范围内我是否有 2 个条件。如果两个条件都满足,我想给它上色。我是这样写的:

Dim ThisRng As Range
Set ThisRng = Application.InputBox("Select a range", "Get Range", Type:=8)
Selection.Activate
Dim cel As Range
For Each cel In ThisRng.Cells
    With cel
   cel.Find("..condition1 to search").Activate
    ActiveCell.Find("...secondcondition").Activate
     ActiveCell.Select
     ActiveCell.Interior.ColorIndex = 33
     ThisRng.Activate

   End With

Next cel

这仅在我的条件为真时有效。如果无法激活该单元格,它会给我一个错误并且不会移动到下一个单元格。

有什么想法吗?

谢谢

这会将任何具有以“,0)”结尾的圆形公式的单元格着色为红色

Sub Demo
Dim ThisRng As Range
Set ThisRng = Application.InputBox("Select a range", "Get Range", Type:=8)
Dim cel As Range
For Each cel In ThisRng.Cells
   if len(cel.formula)>6 then
       if left(cel.formula,6)="=ROUND" and right(cel.formula,3) = ",0)" then
            cel.interior.ColorIndex = 3
       end if
    end if
next cel
End Sub