Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: AUTOFILTER

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have a sheet which I want to filter with a macro.
    I want to filter on column 11 who has the number 1 in it.
    I have made the following macro,but he gives
    me an error.What is wrong?
    Sub Filter()
    Selection.AutoFilter Field:=14,Criteria1:="1"
    End Sub
    Many thanks

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Stockton, California
    Posts
    281
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    try this:
    Sub autofilter()
    Columns("K:K").Select
    Selection.AutoFilter Field:=1, Criteria1:="1"
    End Sub

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-12 01:57, robfo0 wrote:
    try this:
    Sub autofilter()
    Columns("K:K").Select
    Selection.AutoFilter Field:=1, Criteria1:="1"
    End Sub
    Many thanks.It works.
    But how can I set back in the original when I have seen the autofilter?

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Stockton, California
    Posts
    281
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    just issue the :
    Selection.AutoFilter
    in your code again and it will turn off

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Posts
    1,451
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-12 02:08, robfo0 wrote:
    just issue the :
    Selection.AutoFilter
    in your code again and it will turn off
    May I ask you a further question about this autofilter.
    When I have the autofilter,I want this to transfer to another sheet in an other workbook.
    In this case,I want to copy and paste this autofilter from the active workbook to workbook A,sheet 2
    Have you the possibility to give me a macro to do this automatickly?
    Thanks in advance

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Stockton, California
    Posts
    281
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sub autofilter()

    currentworkbook = ActiveWorkbook.Name
    currentsheet = ActiveSheet.Name

    Columns("K:K").Select
    Selection.autofilter Field:=1, Criteria1:="1"
    Range("K1:" & Range("K65536").End(xlUp).Address).Copy
    Workbooks("workbook A.xls").Sheets("Sheet 2").Range("A1").PasteSpecial

    Workbooks(currentworkbook).Sheets(currentsheet).Activate
    Selection.autofilter
    End Sub


    now this assumes you want to paste to workbook "workbook A.xls", sheet "Sheet 2", and range "A1". Also, it assumes both workbooks are already open. if you need to open or close it, just do a search on this board, or a search in the help of vb in excel and youll find it pretty easy. i hope i didnt make any mistakes in that, i didnt test it

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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