Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filer with 3 criteria (2000 sr 1)

    why....?!?!

    If i filer manually the filtre work but if i use the code not show the line....???

    part of code:
    PRIMO = ComboBox1
    SECONDO = ComboBox2
    TERZO = CDate(ComboBox3)

    RNG.AutoFilter Field:=4, Criteria1:=PRIMO
    RNG.AutoFilter Field:=12, Criteria1:=SECONDO
    RNG.AutoFilter Field:=10, Criteria1:=TERZO

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Filer with 3 criteria (2000 sr 1)

    It might have been useful if you hadn't removed all the code/forms from the workbook before posting!

    I suspect your problem is that you need the date formatted correctly:
    <code>TERZO = Format(CDate(ComboBox3), "dd/mm/yyyy")</code>

    or even just:
    <code>TERZO = ComboBox3</code>

    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filer with 3 criteria (2000 sr 1)

    Column J contains a mixture of text values and date values. Since you use CDate, you won't find the text values. Make sure that the contents of column J are consistent.

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filer with 3 criteria (2000 sr 1)

    i have see the prob not is filter....
    But in event change combobox1, combobox2,combobox3...
    When combobox1 change not insert in combobox3 the related dates with filter combobox2 and combobox1...
    HELP,HELP,HELP......

    I use the FUNCTION GetUniqueTipoSosps to fill combobox with filter but not workl correct!!!
    Example:
    when i select item from FIL./GRUPPO (combobox2), CODICE SOSP. combobox1, is filled with all unique value related in a filter with key in combobox2...
    My problem is ...
    When combobox1 change i want toi fill combobox3 with dates relatyed value in combobox1 and combobox2 but not work!!!!!!!

    Example:

    ComboBox2=4507
    ComboBox21 =250008059999

    for me the combobox3 with the condition in combobox1 and combobox2 is 03/02/2007

    but i have:
    29/01/2007
    30/01/2007
    02/02/2007
    03/02/2007


    for test use the simple filter in sheet with the param in combobox1(coloumn D) and combobox2(column L) and see the value with this param in column J is 03/02/2007 and not the list of dates:

    29/01/2007
    30/01/2007
    02/02/2007
    03/02/2007

    attached new file

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filer with 3 criteria (2000 sr 1)

    GetUniqueTipoSosps_1 only compares the value of ComboBox1, it doesn't do anything with the value of ComboBox1. So the dates you get in ComboBox3 are *all* dates for TIPO SOSP. = 250008059999, regardless of the value of FIL. Try this version:

    Private Function GetUniqueTipoSosps_1( _
    ByVal fil As String, _
    ByVal tipo_sosp As String) As Variant
    Set WS = Worksheets("L0953")

    If WS.FilterMode Then
    WS.ShowAllData
    End If

    Set Work = New Collection
    With Worksheets("L0953")
    On Error Resume Next
    For Each CELL In Intersect(.<!t>[D365536]<!/t>, .UsedRange)
    If CELL = fil And CELL.Offset(0, 8) = tipo_sosp Then
    Work.Add CELL.EntireRow.Cells(1, "J"), CStr(CELL.EntireRow.Cells(1, "J"))
    End If
    Next CELL
    On Error GoTo 0
    End With

    ReDim Result_1(1 To Work.COUNT)
    For INDEX = 1 To Work.COUNT
    Result_1(INDEX) = Work(INDEX)
    Next INDEX

    GetUniqueTipoSosps_1 = Result_1
    End Function

    and change both instances of

    ... = GetUniqueTipoSosps_1(ComboBox1)

    to

    ... = GetUniqueTipoSosps_1(ComboBox1, ComboBox2)

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filer with 3 criteria (2000 sr 1)

    Hi Hans... i test in afternoon your suggestion....
    Attached new file...
    Please solve the prob on fileter in commendbutton8 work only 2 criteria the crriteria on column J stiil to no work!!!
    New idea are welcome, sure!

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Filer with 3 criteria (2000 sr 1)

    Sorry, this question is too broad.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •