+ Reply to Thread
Results 1 to 12 of 12

Auto Filter processing all variables

  1. #1
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Auto Filter processing all variables

    I currently use some code in a project like this.

    Please Login or Register  to view this content.
    RegGroup is a list of known values that cell G1 steps through (using a different bit of code thats not important.)

    What i would like to do is for the filter to step through all of the variables in the column rather than a specific filter value being passed to the filter.

    The values will always be a text string and not a number. I'm guessing that i need the code to first test the column for each unique value and then step though each one as the criteria.

    Any ideas?
    Last edited by ianh; 01-26-2012 at 04:56 AM.
    2+2=5 for extremely large values of 2.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto Filter processing all variables

    Please Login or Register  to view this content.



  3. #3
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Auto Filter processing all variables

    Thanks for the suggestion snb but i cannot create a list within the same sheet as done in your example.
    Ideally i don't want to edit the data on/in sheet/workbook.

    Ive attached and example of data. Filtering Example.xlsm

    Often the task im given is to run a report (large data sets from an MIS), apply a filter, and print/PDF separate reports from the output for each of the variables in any given column.

    Not sure if im now making more or less sense.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto Filter processing all variables

    Why not ?
    You can remove those data afterwards.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Auto Filter processing all variables

    the reports will always have a variable number of columns. Although (thinking while im typing) i suppose i could use something to determine the width of the reports first and set the Offset accordingly in your example.

    When i run your example i get an error on the with line "subscript out of range". Is it because i have the name ranged set to the wrong area?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto Filter processing all variables

    yes determining the last column isn't a big deal.

    Yes, it means "table6" doesn't exist.

  7. #7
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Auto Filter processing all variables

    I've checked in name manager and table6 is definitely in there with the range of data.
    I've tried changing it to
    Please Login or Register  to view this content.
    and no joy either.

    What am i missing?

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto Filter processing all variables

    Don't use 'activesheet' but refer to the sheet, using it's name: sheets("sheetname") and if necessary make the reference to the workbook the worksheet belongs to.

  9. #9
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Auto Filter processing all variables

    thanks for your time and patience snb but i just cant get this to work with the example attached.
    I'm clearly making an error but regardless of what i refference in that line i cant get it to execute as expected.

    If possible could you amend the example i've attached in the previous post, your code sample is already in the module, it would be much appreciated.

  10. #10
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Thumbs up Re: Auto Filter processing all variables

    snb, I've got my act together and finally got my head around it.

    Please Login or Register  to view this content.
    Is giving me what i need. I can amend it now to make it fit any of the projects i'm working on (columns and field becoming variables to).

    Again thanks for any time you spent on this it was much appreciated.

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto Filter processing all variables

    I would use this:

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Auto Filter processing all variables

    thanks again snb,

    Your version seems to run quicker as well. not sure if that's just my imagination.

+ 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