我有一个运行过滤器并删除结果的宏,但是今天过滤器结果什么也没带回来,我得到了一个错误。 我要这样做,以便当AV范围中的过滤器什么都没有产生时,只需清除过滤器并结束子
在“ Em Aberto-00”过滤器之后会发生此问题。
我尝试了一些建议,但是作为一个菜鸟,我大多数人无法理解发生了什么
Columns("J:J").Select
Selection.TextToColumns Destination:=Range("J1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 4), TrailingMinusNumbers:=True
Columns("K:K").Select
Selection.TextToColumns Destination:=Range("K1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 4), TrailingMinusNumbers:=True
Columns("BD:BF").Select
Selection.Replace What:="", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.AutoFilter
ActiveWindow.SmallScroll ToRight:=31
Range("AV3").Select
ActiveSheet.Range("$A$1:$BK$3018").AutoFilter Field:=48, Criteria1:= _
"Em Aberto- 00"
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete
ActiveSheet.ShowAllData
End Sub
答案 0 :(得分:0)
执行以下操作:
Dim myRange As Range
On Error Resume Next
Set myRange = Range("your range here").SpecialCells(xlVisible)
On Error GoTo 0
If myRange Is Nothing Then
Exit Sub
Else
'do stuff
End If
您应该避免使用SELECT
,而只能使用Google“如何避免使用SELECT VBA”