Consulting

Page 3 of 3 FirstFirst 1 2 3
Results 41 to 52 of 52

Thread: Solved: filter criteria in active column

  1. #41
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by danovkos
    yes, but it still doesnt works
    but i have other question to this code


    Columns(ActiveCell.Column).AutoFilter field:=ActiveCell.Column, Criteria1:=""

    why this code doesnt works for autofilter, which is doesnt use for all table but only for part of table. If i use this code for autofilter where is autofilter for whole table it works great, but if is table from A to W, but i have filter in first line only for B to D, so it doesnt works- It give criterium to the next column . WHY?
    In code is written "ActiveCell.Column" and this is always the cell where i am or?
    i dont understund it

    The activecell.column is the column nummber, as you know. The Field is the count from the left of the Filter Range, so Filtering E-H, Column F is Field 2, ActiveCell.Column is 6. This is catered for in my last posts.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #42
    no, doesnt works
    if i turned off autofilter and turned on it only for a f.e. column B
    it does what i wrote before. It filtering next column not active column
    ??? why

  3. #43
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by danovkos
    no, doesnt works
    if i turned off autofilter and turned on it only for a f.e. column B
    it does what i wrote before. It filtering next column not active column
    ??? why
    For clarity, to which post are you responding?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #44
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Danovkos, please make some efforts as i explained in a previous post to post your workbook!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #45
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Have you tried stepping through the code to identify the error?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #46
    Quote Originally Posted by Simon Lloyd
    Danovkos, please make some efforts as i explained in a previous post to post your workbook!
    i tried it but it doesnt effect, because of the code for me doesnt works for atached filters.xls too.
    As i wrote.
    It works when i open it, but if i change the autofilter only for a part of table, it stops works and filtering column next active, not active.
    i am really sorry for lost your time i only try to fix my codes

  7. #47
    Quote Originally Posted by mdmackillop
    Have you tried stepping through the code to identify the error?
    yes, but it doesnt show any error. It only after chagne of filter filtering other column as i need.

  8. #48
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Which version of Excel are you using? Not that I think it should make a difference.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #49
    Quote Originally Posted by mdmackillop
    Which version of Excel are you using? Not that I think it should make a difference.
    Office 2003 with SP3

  10. #50
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I can test in that later.

    One last attempt for now. Try this version in the Userform example
    [VBA]
    Sub Filtering2(Flt As String)
    Dim FiltRng As Range
    Dim Col As Long
    Set FiltRng = ActiveSheet.AutoFilter.Range
    Col = Selection.Column - FiltRng(1).Column + 1 '<++++++++++++
    If FiltRng.Columns.Count = 1 And Col = 0 Then Col = 1
    FiltRng.AutoFilter field:=Col, Criteria1:=Flt
    End Sub

    [/VBA]

    If that fails, try changing the indicated 1 value to 0 to see if it helps
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  11. #51
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I've tried this in 2003 and 2007 and it works in both. Some error handling has been added. If this isn't it, I don't know what else to suggest.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  12. #52
    yes, yes, yes
    it works perfec...and the second code with useform is great too. I give there my most used criteria and will always use it )
    thanke you very very much to all.

Posting Permissions

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