+ Reply to Thread
Results 1 to 2 of 2

Advanced Filter VBA - Adding More Criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    08-05-2007
    Posts
    11

    Advanced Filter VBA - Adding More Criteria

    Hey Everyone.
    I downloaded an Advanced Filter Macro from Contextures.com (http://www.contextures.com/AdvFilterSearchWord.zip) and it works great.

    I was wondering if anyone can help me set more criteria.

    On the Worksheet it has the code

    =AND(OR($B$1="",D7=$B$1),ISNUMBER(SEARCH($A$1,B7)))

    On the VBA Worksheet Code Is This:

    Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Address = "$A$1" Or _
    Target.Address = "B$1" Then _
    Range("Database").AdvancedFilter _
    Action:=xlFilterInPlace, _
    CriteriaRange:=Range("Criteria"), Unique:=False
    End If
    End Sub




    How can I add more Criterea to search more columns? Thanks Guys

  2. #2
    Registered User
    Join Date
    08-05-2007
    Posts
    11
    Cancel That. Found Something Easier and have run into another problem. If not all fields are entered in my userform, it doesnt work. Returns empty spaces.

    Private Sub SearchFromButton_Click()

    Unload Me
    Application.ScreenUpdating = False
    Sheets("Database").Select

    Range("A1").AutoFilter Field:=1, Criteria1:=Me.searchbypurchaseorder.Value
    Range("A1").AutoFilter Field:=2, Criteria1:=Me.searchbyarea.Value
    Range("A1").AutoFilter Field:=4, Criteria1:=Me.searchbymonth.Value
    Range("A1").AutoFilter Field:=7, Criteria1:=Me.searchbyconveyance.Value
    Range("A1").AutoFilter Field:=8, Criteria1:=Me.searchbyfrom.Value
    Range("A1").AutoFilter Field:=9, Criteria1:=Me.searchbyto.Value
    Range("A1").AutoFilter Field:=12, Criteria1:=Me.adnicbutton.Value
    Range("A1").AutoFilter Field:=12, Criteria1:=Me.saicobutton.Value

    Application.ScreenUpdating = True

    End Sub

+ Reply to Thread

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