我正在尝试从excel表中删除所有“ 0”值。我编写了以下代码,但它返回方法“对象'_Worksheet'的范围”失败。我该怎么做才能解决此问题?
Sub Macro()
Dim ws As Worksheet
''Set reference
Set ws = ThisWorkbook.Worksheets("Compressed Schedule results")
''Apply Filter
ws.Range("A2:B2").AutoFilter Field:=1,Criteria1:="0"
lrow = activeSheet.Cells(Rows.Count,"A").End(xlUp).SpecialCells(xlCellTypeVisible).Row
''Delete the Rows
Application.DisplayAlerts = False
ws.Range("A2:lrow").SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
ws.ShowAllData
End Sub