Consulting

Results 1 to 4 of 4

Thread: Testing whether filtering is active.

  1. #1

    Testing whether filtering is active.

    Hey guys,

    I have a macro that filters on different columns depending on what option is selected on a userform. This works fine when the filtering is already switched on on the worksheet but falls over when there is none.

    Is there a way of saying like
    If autofiltering is off then
    switch it on

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Check out

    [vba]

    ActiveSheet.AutoFilterMode
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    So I want something like
    [VBA]
    If Not ActiveSheet.AutoFilterMode Then
    ActiveSheet.AutoFilterMode = True
    End If
    [/VBA]

    But this doesn't work, the test on the if statement seems to work but I can't get it to turn on the filter. Have I been too hopeful on how easy that step is?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No, you have to set the filter, which means identifying the range to be filtered, and the column within that range.

    If you read the help, you will see that you can set it to false to remove the arrows, but you cannot set it to tru.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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