How do I get this code to run consistently without error?
I recently received MrExcel help for the code below. At first it didn’t work; I was getting a runtime error. Then on Friday it did work (!!) without any edits in this code, and today I’m again seeing “Runtime error 1004: Autofilter method range class failure” in the second line of code.
With Worksheets("Provider").Range(Cells(8, 1), Cells(intLastRowN, intLastCol))
.AutoFilter Field:=intBCOCol, Criteria1:="Y"
.AutoFilter Field:=intBCOExcCol, Criteria1:="OUT"
End With
Nothing is random in VBA.
On the first line, when I hover over the word “Cells” in Cells(intLastRowN, intLastCol): it shows “Cells(intLastRowN, intLastCol)=Error 2042” even though the content of intLastRowN and intLastCol are correct (2477 and 26, respectively).
Is error 2042 the source of my trouble? I do have “N/As” in the intBCOExcCol column.
I recently received MrExcel help for the code below. At first it didn’t work; I was getting a runtime error. Then on Friday it did work (!!) without any edits in this code, and today I’m again seeing “Runtime error 1004: Autofilter method range class failure” in the second line of code.
With Worksheets("Provider").Range(Cells(8, 1), Cells(intLastRowN, intLastCol))
.AutoFilter Field:=intBCOCol, Criteria1:="Y"
.AutoFilter Field:=intBCOExcCol, Criteria1:="OUT"
End With
Nothing is random in VBA.
On the first line, when I hover over the word “Cells” in Cells(intLastRowN, intLastCol): it shows “Cells(intLastRowN, intLastCol)=Error 2042” even though the content of intLastRowN and intLastCol are correct (2477 and 26, respectively).
Is error 2042 the source of my trouble? I do have “N/As” in the intBCOExcCol column.