Results 1 to 14 of 14

Thread: [RESOLVED] How to use Excel.Range.AutoFilter method

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    73

    Resolved [RESOLVED] How to use Excel.Range.AutoFilter method

    Hi C# Guys,

    I'm new in using Excel automation (Excel Primary Interop), I need to know how to use Excel.Range.AutoFilter method correctly.. Do you have any idea how can I use this properly in my program??? Thank you guys.. Happy New Year to all of you..

    Happy Programming,
    den

  2. #2
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to use Excel.Range.AutoFilter method

    Welcome to VBForums.

    Just want to ask what do you want to do with Excel.Range.Autofilter?
    Rate Me! Rate Me! Rate Me!

    Time to fly.

    Copyright GraysonSoft Inc. 2007

  3. #3
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to use Excel.Range.AutoFilter method

    Try this:

    VB Code:
    1. Excel.Range("A1:Z23").Autofilter

    This is what the macro recorded when I used the Autofilter.
    Rate Me! Rate Me! Rate Me!

    Time to fly.

    Copyright GraysonSoft Inc. 2007

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    73

    Re: How to use Excel.Range.AutoFilter method

    Through Excel.Range.AutoFilter method, I think I can filter all the records in the cell by ascending, descending, top 10 items.. the usual filter items of AutoFilter method.. thanks

  5. #5
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to use Excel.Range.AutoFilter method

    Ah ok. Have you tried my suggestion?
    Rate Me! Rate Me! Rate Me!

    Time to fly.

    Copyright GraysonSoft Inc. 2007

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    73

    Re: How to use Excel.Range.AutoFilter method

    I tried it however the code didn't make sense in c# code =) syntax may differ.. What I want to be outputed in my excel automation is, once the excel is generated, the columns will have a dropdown list containing choices like: ascending, descending, top10Items, etc.. and once I choosed an item among the choices, the records in the cells will respond accordingly =)

  7. #7
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to use Excel.Range.AutoFilter method

    Post us the code so that we may know the proper syntax.

    Rate Me! Rate Me! Rate Me!

    Time to fly.

    Copyright GraysonSoft Inc. 2007

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    73

    Re: How to use Excel.Range.AutoFilter method

    Thanks tommygrayson i solved my problem!!! =) here is my code to share to all of you:

    "c#"
    range = workSheet.get_Range("A2", m_objOpt);
    range.AutoFilte(1, "<0",Excel.XlAutoFilterOperator.xlOr, "<100",Type.Missing);


    you should load first the item from the database or any data sources in cells before invoking this code. =)

    regards to you..

  9. #9
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to use Excel.Range.AutoFilter method

    Ok. Just remember to mark this thread as resolved so that others will know that your problem has been resolved.

    Also don't forget to go to VBForums in case you need help.
    Rate Me! Rate Me! Rate Me!

    Time to fly.

    Copyright GraysonSoft Inc. 2007

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    73

    Re: How to use Excel.Range.AutoFilter method

    thanks tommy! how will I mark this thread as resolved?

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to use Excel.Range.AutoFilter method

    Use the Thread Tools menu > Mark thread as Resolved.

    I have some C# Excel code examples in my Office FAQ too just in case.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    73

    Re: How to use Excel.Range.AutoFilter method

    thanks Master. where is the Thread Tools menu? is it in the C# page?.. thanks

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to use Excel.Range.AutoFilter method

    Quote Originally Posted by denvercr
    thanks Master. where is the Thread Tools menu? is it in the C# page?.. thanks
    Scroll up to the first post in this thread. Above it you will see a menu item called "Thread Tools". Click on it, and the menu item for resolving a thread will be there.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    73

    Re: [RESOLVED] How to use Excel.Range.AutoFilter method

    thanks Hack!! I got it =)

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