Results 1 to 2 of 2

Add additional filter criteria depending on cell value

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Add additional filter criteria depending on cell value

    Hi,

    Seems like an easy issue, but I can't seem to find the right code to do what I'm after.

    I have code that applies an auto filter to a certain column. What I want to do is apply an additional filter to a second column dependent on a cell value on another sheet.

    The code below comes up with the following error:
    Run-Time error '-2147417848 (80010108)'
    Automation error
    The object invoked has disconnected from its clients

    I'm assuming this is because I'm trying to run an 'If' statement from within a 'With' statement. I've tried re-selecting/defining the sheet and range, but still no luck Can someone point me in the right direction please?


            With Sheets("Sheet1")
                .Activate
                .AutoFilterMode = False
                .Range("A:BP").AutoFilter
                    Selection.AutoFilter Field:=68, Criteria1:=Customer, Operator:=xlFilterValues
                        
                        If Worksheets("Sheet3").Range("E6").Value = "Month" Then
                                        Selection.AutoFilter Field:=7, Criteria1:=Mnth, Operator:=xlFilterValues
                        End If
                
                .Range("A:B, D:D, U:U, BP:BP").Copy _
                    Destination:=Sheets("Sheet2").Cells
                .Range("F:F, L:L").Copy _
                    Destination:=Sheets("Sheet2").Range("F1")
            
            End With
    Last edited by dancing-shadow; 06-14-2017 at 10:48 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Count cells in range that match corresponding cell, and meet an additional criteria.
    By Nyima in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-15-2016, 04:11 PM
  2. Set a filter in a table depending on content of cell
    By fxmu in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-14-2015, 09:55 PM
  3. additional value to a cell based on criteria from another cell
    By JohnnyBoyxxx in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2014, 07:39 AM
  4. If a cell does NOT contain... And additional criteria
    By kestefon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-14-2013, 03:47 PM
  5. Replies: 1
    Last Post: 07-05-2013, 08:40 PM
  6. Populating additional sheets with data from sheet 1 depending on info in cell
    By kd1950 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2012, 09:42 PM
  7. Auto Filter depending on cell values
    By foxglove666 in forum Excel General
    Replies: 1
    Last Post: 05-01-2008, 05:01 PM

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