+ Reply to Thread
Results 1 to 3 of 3

Excel 2010 : Macro to rotate auto-filter

  1. #1
    Registered User
    Join Date
    03-24-2017
    Location
    Brighton
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    3

    Excel 2010 : Macro to rotate auto-filter

    Hi

    I found this article which contains an example of a macro that rotates through the auto-filter
    https://sites.google.com/a/madrocket...uto-autofilter

    I've almost got it working on my spreadsheet by changing 'AFCol' to 16 as I'm filtering column 'P'
    But I can't figure out how to amend the code so that the auto-filter appears on row 7 instead of 1

    I tried changing the last few lines from this:

    Columns(AFCol).AutoFilter
    Columns(AFCol).AutoFilter Field:=1, Criteria1:=CurrCrit

    To this instead:

    Range("P7:P500").AutoFilter
    Range("P7:P500").AutoFilter Field:=1, Criteria1:=CurrCrit

    Which puts the auto-filter in the right place, but it no longer works/selects the next item when run :/

    Any help would be appreciated
    Kind regards
    Vicky

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Excel 2010 : Macro to rotate auto-filter

    try changing

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    Last edited by BellyGas; 03-27-2017 at 08:36 AM.

  3. #3
    Registered User
    Join Date
    03-24-2017
    Location
    Brighton
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    3

    Re: Excel 2010 : Macro to rotate auto-filter

    Thanks BellyGas

    So I just got this working. I removed AFCol completely and hard coded my range in. Not good practice I know
    But it's working perfectly to rotate a filter on cell P7 now

    ----

    Option Explicit
    Public CurrCrit As String

    Sub AutofilterRotate()
    Dim rFind As Long

    Application.ScreenUpdating = False
    ActiveSheet.AutoFilterMode = False

    If CurrCrit = "" Then
    CurrCrit = Cells(8, 16).Value
    Else
    Columns("P:P").AdvancedFilter Action:=xlFilterCopy, _
    CopyToRange:=Range("AA1"), Unique:=True
    rFind = Columns("AA:AA").Find(CurrCrit, After:=[AA7], _
    LookIn:=xlValues, LookAt:=xlWhole).Row
    CurrCrit = Range("AA" & rFind + 1)
    If CurrCrit = "" Then CurrCrit = Range("AA8").Value
    End If

    Columns("AA:AA").ClearContents

    Range("P7:P500").AutoFilter
    Range("P7:P500").AutoFilter Field:=1, Criteria1:=CurrCrit
    Application.ScreenUpdating = False
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 04-03-2014, 11:41 AM
  2. Macro to Auto-adjust print area in a multiple sheets (excel 2010)
    By ALNER in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2014, 10:11 AM
  3. How to rotate a data Table in Excel 2010? (NOT TRANSPOSE)
    By jamonzonv in forum Excel General
    Replies: 1
    Last Post: 09-23-2013, 06:12 AM
  4. [SOLVED] What is the fix for jagged text on Rotate Text Up - Excel 2010, Windows 7
    By bordercollie in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 12-26-2012, 03:45 PM
  5. Why does an embedded word doc not auto-update in macro-enabled excel doc 2010?
    By Ryan Nielsen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-26-2012, 03:59 PM
  6. Excel 2010 to auto-generate an email to recipients in outlook 2010
    By dmcmillo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2012, 05:13 PM
  7. [SOLVED] Macro for Auto Inserting a Number Incrementally (+1) in the footer of Excel 2010
    By bobbyd98682 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2012, 03:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1