Results 1 to 2 of 2

Dynamic filters (different strings) for multiple sheets in the same workbook

Threaded View

  1. #1
    Registered User
    Join Date
    10-29-2014
    Location
    Germany
    MS-Off Ver
    no idea
    Posts
    2

    Dynamic filters (different strings) for multiple sheets in the same workbook

    I am pretty new to VBA and i am still in the learning phase. I have posted my earlier issue on this forum although no one could really help http://http://stackoverflow.com/ques...-sheets-in-the

    I have a sheet named 'Anwendung' in a workbook where in column AI there are different fields based on which i am filtering. In this case it would be 'Anwendung'. For this i have managed to google and tweak certain section of the code and the code looks like this
    Sub DynamicFilter()
    SearchCol = "Typ"
    SearchFor = "Anwendung"
    Set rng1 = ActiveSheet.UsedRange.Find(SearchCol, , xlValues, xlWhole)
    Range("A1").Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=rng1.Column, Criteria1:=SearchFor
    End Sub
    Now i have a couple of other sheets in the workbook where i need to filter them according to other strings for e.g. Sheet Name= 'Ressourcen'has a field named 'Ressourcen' in column AI. With the above stated code i can just apply it for the active sheet and not the entire work book and other subsheets within the workbook.

    If i define `Dim ws As Worksheet` and then run a for loop in it. Then it filters all the sheets in the workbook with 'Anwendung' as filter criteria and for certain sheets the filter criteria is different. for e.g. Sheet Name= Ressourcen, the filter criteria is 'Ressourcen' in Column AI.

    Sub DynamicFilter()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
    ws.Activate
    SearchCol = "Typ"
    SearchFor = "Anwendung"
    Set rng1 = ActiveSheet.UsedRange.Find(SearchCol, , xlValues, xlWhole)
    Range("A1").Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=rng1.Column, Criteria1:=SearchFor
    Next ws
    End Sub
    All i need is how can i define multiple filters for multiple sheets. Filter 1 'Anwendung' for a sheet 1 named Anwendung and Filter 2: 'Ressourcen' for sheet 2 named Ressourcen as a filter for another sheet and so on.

    I would really be grateful if any of you can help me.
    Last edited by wildradical; 11-03-2014 at 08:22 AM. Reason: Ignored the forum rules

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to copy cells from multiple sheets in workbook to multiple sheets in other workbook
    By KeithMale in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 05:37 PM
  2. Doing multiple filters information from another workbook
    By denfan in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 03-21-2013, 01:28 PM
  3. [SOLVED] Excel Compare Strings in Multiple Sheets
    By Nu2Java in forum Excel General
    Replies: 3
    Last Post: 08-25-2012, 08:09 AM
  4. Replies: 4
    Last Post: 07-24-2012, 01:21 PM
  5. Turn filters on in multiple sheets
    By EstherJ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-05-2005, 01:05 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