効果がない場合は、フィルタを適用するだけでフィルタをクリアすることができます。
Sub ClearAutoFilterIfNoEffect()
Dim countVisibleRows1 As Long
Dim countVisibleRows2 As Long
Dim r As Range
countVisibleRows1 = WorksheetFunction.Subtotal(103, Range("$A$1:$N$" & i))
Range("$A$1:$N$" & i).AutoFilter Field:=14, Criteria1:=Array("String1", "string2", "string3"), Operator:=xlFilterValues
countVisibleRows2 = WorksheetFunction.Subtotal(103, Range("$A$1:$N$" & i))
If countVisibleRows2 = countVisibleRows1 Then
If ActiveSheet.AutoFilterMode Then Cells.AutoFilter
End If
End Sub
そうしないと、各条件
Sub CheckAllConditionsBeforeApplyingFilter()
With Range("$A$1:$N$" & i)
If .Cells.Find(what:="string1", LookIn:=xlFormulas, lookat:=xlWhole) Is Nothing Then
If .Cells.Find(what:="string2", LookIn:=xlFormulas, lookat:=xlWhole) Is Nothing Then
If .Cells.Find(what:="string1", LookIn:=xlFormulas, lookat:=xlWhole) Is Nothing Then
'Clear the filter if it exists
If ActiveSheet.AutoFilterMode Then Cells.AutoFilter
Exit Sub
Else
.AutoFilter Field:=14, Criteria1:=Array("String1", "string2", "string3"), Operator:=xlFilterValues
End If
End If
End If
End With
End Sub
私は助けることができるとうれしいをチェックする必要があります! –