Results 1 to 13 of 13

Filters with three criteria in semi-ready code

Threaded View

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Filters with three criteria in semi-ready code

    Attachment 147609Hi..
    I'd like to make an adjustment in the code below.

    How can I use this code, made by my friend Jaslake, to use it with three criteria?

    I need to fetch the data sheet of "origin", using the three criteria that are in cell "A2, B2, C2" worksheet "Destination", and play the result in "A6" worksheet "Destination".

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim ws As Worksheet
        Dim LR As Long
        Dim LC As Long
    
        Set ws = Sheets("Origin")
        If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
        If Target.Address = "$A$2 $B$2 $C$2" Then
            Sheets("origin").UsedRange.Offset(5, 0).Clear
    
            With ws
                LR = .Cells.Find("*", .Cells(Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                        SearchDirection:=xlPrevious).Row
                LC = .Cells.Find(What:="*", After:=[A1], _
                        SearchOrder:=xlByColumns, _
                        SearchDirection:=xlPrevious).Column
                .Cells(1, 1).AutoFilter Field:=1, Criteria1:=Target.Value
                .AutoFilter.Range.Copy
                Sheets("Destination").Range("A6").PasteSpecial
                .AutoFilterMode = False
                Application.CutCopyMode = False
            End With
        End If
       
    End Sub
    Attached Files Attached Files
    Last edited by Vaibhav; 04-14-2012 at 09:47 PM.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

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