Excel error with intersect code

时间:2015-06-30 19:24:02

标签: excel vba excel-vba

Good afternoon! I'm having another issue, and can't seem to figure it out. In this way too long filter macro, I have code that looks for the active cell within a range, and if it's there, performs a filter:

       ElseIf Not (Intersect(ActiveCell, OpenFindingsRange)) Then
    SourceFindings.Select
        'Unfilter data
        Application.Goto (Sheets("Source-Findings").Range("A1"))
        If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData

    ActiveSheet.ListObjects("tblFindings").Range.AutoFilter Field:=6, Criteria1:=FilterOperatingGroup
    ActiveSheet.ListObjects("tblFindings").Range.AutoFilter Field:=36, Criteria1:=OpenStatus
    ActiveSheet.ListObjects("tblFindings").Range.AutoFilter Field:=37, Criteria1:="Yes"

If the active cell isn't in that range, it should go to the next Else If statement, but that's not happening. I'm getting the following error: Object variable or With block variable not set.

I can't get around this, and for whatever reason, I can't get error handling to bypass it.

Thoughts?

Thx!

1 个答案:

答案 0 :(得分:2)

Intersect(),在您使用它时,将返回范围而不是布尔值。