+ Reply to Thread
Results 1 to 5 of 5

Automatically select Filter items

  1. #1
    Registered User
    Join Date
    02-22-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2003
    Posts
    36

    Automatically select Filter items

    I have a VBA macro on Excel I wrote at work to print some reports. I'm always looking into making more automatical steps, and I haven't found an example on how to do this yet.

    The last step essentially has me manually select each item in the filter list of a column, one by one, printing each. The column is always the same, but the list's content will vary as it's based off unique invoice numbers.

    I was wondering if there was an easy way to do this, something like For Each X in FilterList or Filterlist(X).select . It's probably not as simple, but that's why I'm here

    Thanks in advance!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatically select Filter items

    Actually, you got it on the head. I do this very thing frequently.

    I use the ADV Filter to copy a UNIQUE VALUES list to another empty column, sort it, then filter the original column by the unique values in a loop. Very efficient.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 02-22-2010 at 01:58 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-22-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Automatically select Filter items

    Hmmm.

    Well this works fine for the purpose of printing, but I've ran into a small difference, wondering how I can get around it.

    When I was doing it manually, it was keeping the total at the bottom, so I'd have a dynamic total of the currently selected filter item printed. But when using your macro that total disapears.

    Maybe I need to space the total by one more row?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatically select Filter items

    Quote Originally Posted by Franck Knight View Post
    Maybe I need to space the total by one more row?
    That would do it. The Autofilter filters the concurrent range of data, so that would fix it, I'd think.

  5. #5
    Registered User
    Join Date
    02-22-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2003
    Posts
    36

    Re: Automatically select Filter items

    Adding a new line didn't fix it right away, but I found a work around.

    I think Excel 2003 AutoFiltering system is a bit messed up. I tried adding a new line, but since the totals are in a different column (N-O in my case) than the filtering column (B), Excel was doing what it wanted and hiding it.

    First I changed the AutoFilter range of your Macro from A:A to Rows(1:1).Autofilter. That's what my macro originally had and it woked for me with the total row. But yours specified columns instead, so Excel behaves differently for some reason, and the AdvancedFilter you apply at the begining of it remoevs what AutoFilter I had beforehand, so I have to place a new one.

    Rows(1:1).Autofilter puts on every column that has data (which included your EE even though it was erased, so I modified it to a closer Q:Q in my case). After that, I modified that last Autofiltering line to be Range(A:O) and it seems to not hide the total row anymore.

    Thanks for the help Hope this info will help similar problems as well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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