I'm either trying to make this too simple or not complex enough... I'm trying to add in a simple qualifier as to whether a macro will run. It heads up the code with nothing in front of it and the macro would run completely fine without it. Here's the code:
Range("K1").Formula = "=countif(E2:E500, 0)"
If Range("K1") = 0 Then MsgBox "No agents to remove", vbOKOnly + vbInformation
Exit Sub
End If
The code continues on to run the filter, sort and remove macro I've written. But I get the error "End If without block IF" highlighting the above.
If I remove the End IF and the countif results >0, then the macro still doesn't run.
What am I doing wrong?
Range("K1").Formula = "=countif(E2:E500, 0)"
If Range("K1") = 0 Then MsgBox "No agents to remove", vbOKOnly + vbInformation
Exit Sub
End If
The code continues on to run the filter, sort and remove macro I've written. But I get the error "End If without block IF" highlighting the above.
If I remove the End IF and the countif results >0, then the macro still doesn't run.
What am I doing wrong?