Consulting

Results 1 to 6 of 6

Thread: Solved: script to highlight autofilter header

  1. #1
    VBAX Regular
    Joined
    Aug 2011
    Posts
    60
    Location

    Solved: script to highlight autofilter header

    Hi all,

    I'm looking for a script that will highlight any autofilter header when the filter is applied. Let's say I have autofilter ON for cell B2, C2, G2. I want these row headers to be highlighted so I can know that there is an filter being applied there. Appreciate that.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Doesn't the little filter symbol already do that for you?
    ____________________________________________
    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
    what version are you using?

  4. #4
    VBAX Regular
    Joined
    Aug 2011
    Posts
    60
    Location
    Hi xld,

    Yes. That is indeed true. But my sheet consist of a lot of columns (currently working at 57 over columns and counting) and that kinda makes it hard to spot on directly when you have several filters on at the same time. Makes is quite taxing on the eye.

    So I if I can work out a header highlight, I can see instantly that there is a filter on in that particular column. I do hope you get what I mean.

  5. #5
    VBAX Contributor
    Joined
    Mar 2007
    Posts
    140
    Location
    Hello alloy78,

    I found this on 'Andrew's Excel Tips' (http://blog.livedoor.jp/andrewe/archives/19415538.html) and have found it very useful.
    If applied to the heading cell/s where the AutoFilter is applied the cell/s background changes to whatever colour you have chosen.

    Enter the following in a standard module:
    Function FilterOn(myCell As Range) As Boolean
      On Error Resume Next
      With myCell.Parent.AutoFilter
        With .Filters(myCell.Column - .Range.Column + 1)
          If .On Then FilterOn = True
        End With
      End With
    End Function
    Then using Conditional Formatting, enter =filteron(your cell reference). (Format > Conditional Formatting > Formula Is).

    Regards,
    Dave T

  6. #6
    VBAX Regular
    Joined
    Aug 2011
    Posts
    60
    Location
    Hi Dave,

    Thanks. Exactly what i was looking for.

Posting Permissions

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