Here is the code below. It works perfectly when I step into the sub routine and continually hit F8 but not when the button is hit in the excel sheet.
PHP Code:
Sub ClearFilter_Click()
Dim route As Object
Dim total, routecount, x As Integer
total = 0
For Each route In ActiveSheet.Range("AU1: AU350")
ActiveSheet.Range("D1").Clear
x = route.Value
ActiveSheet.Range("D1").Value = x
Data.Range("OutOfSequence[[#All],[WaveNumber]:[Out of Order?]]").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Data.Range _
("AO1:BZ2"), Unique:=False
routecount = Application.WorksheetFunction.CountIf(Range("OutOfSequence[Out of Order?]"), "YES")
total = total + routecount
ActiveSheet.Range("D7") = total
Next route
ActiveSheet.Range("D7") = total
End Sub
Bookmarks