+ Reply to Thread
Results 1 to 2 of 2

Auto-Filter on multiple worksheets automatically via VBA

  1. #1
    GLT
    Guest

    Auto-Filter on multiple worksheets automatically via VBA

    Hi,

    I am trying to use VBA to select 4 worksheets and run an Autofilter in
    Column H (column # 8) on each sheet.

    Each sheet is labelled from Jobsheet 1 ... 4.

    The Autofilter criteria is "ALL" or myDay1

    myDay1 = variable which contains the first 2 letters of the day (ie. MO TU WE)

    When I run this code, I get a runtime error 13. Can anyone tell what I am
    doing wrong or a better way to write this code?

    For daLoop = 1 To 4

    jobStream = "Jobstream " & daLoop
    MsgBox jobStream

    Sheets(jobStream).Select
    Selection.AutoFilter Field:=8, Criteria1:="ALL" Or myDay1

    Next daLoop

    Cheers,
    GLT



  2. #2
    Tom Ogilvy
    Guest

    Re: Auto-Filter on multiple worksheets automatically via VBA

    apply the two filters to your range (using the custom option) with the macro
    recorder turned on. It will show you how to do it.

    --
    Regards,
    Tom Ogilvy


    "GLT" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I am trying to use VBA to select 4 worksheets and run an Autofilter in
    > Column H (column # 8) on each sheet.
    >
    > Each sheet is labelled from Jobsheet 1 ... 4.
    >
    > The Autofilter criteria is "ALL" or myDay1
    >
    > myDay1 = variable which contains the first 2 letters of the day (ie. MO TU

    WE)
    >
    > When I run this code, I get a runtime error 13. Can anyone tell what I am
    > doing wrong or a better way to write this code?
    >
    > For daLoop = 1 To 4
    >
    > jobStream = "Jobstream " & daLoop
    > MsgBox jobStream
    >
    > Sheets(jobStream).Select
    > Selection.AutoFilter Field:=8, Criteria1:="ALL" Or myDay1
    >
    > Next daLoop
    >
    > Cheers,
    > GLT
    >
    >




+ 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