Results 1 to 9 of 9

Thread: AutoFilter lessthan greater than

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    19

    AutoFilter lessthan greater than

    Hi guys,
    I need help autofilter a table based on a high and low range determined by another sheet. below is the macro i recorded...

    Selection.AutoFilter Field:=6, Criteria1:="<26", Operator:=xlOr, _
    Criteria2:=">23"


    say the data table is on sheet2, what i need is to filter the table to show data between the values of sheet1 cell a1 and sheet1 cell a2.

    thanks

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    19

    Re: AutoFilter lessthan greater than

    looks like i stumped a few

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: AutoFilter lessthan greater than

    If you OR you will bring back everything

    How are you setting the autofilter? Code from a menu button?
    You'd need a reference to sheet2, then use sheet2s autofilter, and change the xlor to xland.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    19

    Re: AutoFilter lessthan greater than

    The xland...xlor isn't my issue. I need to figure out how to reference a cell in another sheet from the autofilter sub.

    What i am doing is taking a data sheet (12000+ rows and 23 columns) for an IRL practice session and filtering out specific drivers then filtering out lap times between a max and min time.

    If you haven't figured it out yet I'm NOT a programmer.

  5. #5
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: AutoFilter lessthan greater than

    I don't think you can directly reference to the other sheets cells, but you can run a macro that does reference those cells and then sets the autofilter.

    See attached
    Attached Files Attached Files

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    19

    Thumbs up Re: AutoFilter lessthan greater than

    That does exaclty what i needed it to. Thank you very much!

    p.s. What books would you suggest picking up to help me learn Excel VBA?
    Last edited by meredth78; Jun 12th, 2007 at 09:22 AM.

  7. #7
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: AutoFilter lessthan greater than

    I'm not sure. Wrox do some really good books and my preference is for Sybex. O'reilly are pretty good.

    one thing to look for is the level it is aimed at.
    If you go beginner -> intermediate, the book is likely not to be used once you get there. But if you don't mind stretching a bit usually I go for an intermediate to advanced. especially if it is written well and can be used as a reference guide. Sybex book I got for Access were like that.


    Alternatively you can record most macros, see how excel does it then change all the selection objects into their relevant objects (selection of cell(s) is a range, activeworksheet is a sheet or worksheet etc).
    Best thing is if people can give you different tasks to complete on a spreadsheet. You know, the repetative ones that don't require much thought. Like the formatting of sheets, perhaps auto generation of pivot tables from a table/file of data. Simple processing. Ecah of these allows you to experiment with coding in different ways and get better with a goal to achieve at the end.

    If you look around your office, you should find some of these... or perhaps some paper based tracking or something you can try to convert into sheets and practice your coding.

    Oh and with the books, try to get your hands on them first to flick through. Search online for the books (amazon?) and write down the titles. Go to the local book store and see if they have them. Spend 5 mins or so leafing through and see if the style of the book suits you. Then you can either buy immediately or order on line (possibly cheaper). Alternatively some older books (still good) will be available at car boot sales, computer shows, or on old stock going out of book stores. might be worth a quick browse there too.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    19

    Re: AutoFilter lessthan greater than

    Thanks Ecniv.

    Will the VBA for Office 2007 be the same as '03, with the exception of added features?
    Last edited by meredth78; Jun 18th, 2007 at 08:33 AM.

  9. #9
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: AutoFilter lessthan greater than

    Not sure. As far as I know yes should still work. Depends if they have moved toward .Net or not. Post up if you find out.

    If the code does not debug>compile... Then MS changed things.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Click Here to Expand Forum to Full Width