Results 1 to 2 of 2

Thread: AutoFilter With block variable not set

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    AutoFilter With block variable not set

    Something very strange is going on.
    I have a spreadsheet saved with an autofilter on.
    I then call one method (via a button) which fills some data and does some filtering.
    I then change one of the filtered (visible) cells from N to Y.
    However, when I call the next method (via a second button) I get error 91 when trying to address the range
    i.e.
    Code:
    Private Sub cmdDownload_Click()
        Dim rngFilter As Range
        Set rngFilter = Sheet14.AutoFilter.Range
    gives
    Code:
    Object variable or With block variable not set
    Also checking AutoFilterMode returns false
    Code:
    Private Sub cmdDownload_Click()
        If AutoFilterMode = False Then
            Sheet14.Range("B11").AutoFilter
        End If
        Dim rngFilter As Range
        Set rngFilter = Sheet14.AutoFilter.Range
    This then has the effect of REMOVING the autofilter that was previously on. (Because it thinks it is off when it isn't "Sheet14.Range("B11").AutoFilter" has the effect of turning it off instead of on)

    If I put 2 such blocks, I end up with the AutoFilter displayed on screen.
    However, I still get the error when I try to set my range.

  2. #2

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Re: AutoFilter With block variable not set

    An interesting development!
    I actually inherited the original sheet and it looks like the autofilter is actually part of a List (or Table in 2007 parlance).
    I've converted it to a normal range (i.e. got rid of it) and so far the problem hasn't recurred.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width