Results 1 to 13 of 13

Problem with Autofilter Criteria in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    06-23-2012
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2007
    Posts
    47

    Problem with Autofilter Criteria in VBA

    I'm attempting to automate a daily report that I have but I'm running into trouble with the use of autofilter in VBA. The first value that I am attempting to calculate is the "average cycle time" in "sheet1" column G. I have several criteria that need to be applied but for some reason when I run the VBA I can't get the selection of criteria right. The multiple criteria should be returning several rows of results upon which the "average cycle time" bases its calculation, but the autofilter is returning only one row which isn't correct. It would be much appreciated if anyone can take a look at this and tell me where I'm going wrong.

    [CODE]Sub Filter_Stuff()
    Dim LR As Long, idate As Long, iMonth As Long, idynrange As Long, AR As Variant

    ' With Sheets("Sheet1")
    ' If Not .AutoFilterMode Then
    ' .Range("a1").AutoFilter
    'End If


    idate = Sheets("Totals").Cells(2, 8).Value
    iMonth = Sheets("Totals").Cells(2, 9).Value

    'iDate = "=*" & iYear & "*"
    'iMonth = "=*" & iMonth & "*"


    Sheets("Sheet1").Activate
    idynrange = Range("a" & Rows.Count).End(xlUp).Row + 1
    'Sheets("Sheet1").Rows("1:1").Select
    Sheets("Sheet1").Range("$A$1:$AZ$" & idynrange).Select
    Selection.AutoFilter
    Sheets("Sheet1").Range("$A$1:$AZ$" & idynrange).AutoFilter Field:=4, Criteria1:=idate

    Sheets("Sheet1").Range("$A$1:$AZ$" & idynrange).AutoFilter Field:=6, Criteria2:="<=15"

    Sheets("Sheet1").Range("$A$1:$AZ$" & idynrange).AutoFilter Field:=1, Criteria3:="BOB"
    Sheets("Sheet1").Range("$A$1:$AZ$" & idynrange).AutoFilter Field:=5, Criteria4:="=NEW", Operator:=xlOr, Criteria2:="=Refill"

    Sheets("Sheet1").Range("g2").CurrentRegion.SpecialCells(xlCellTypeVisible).Cells(2, 7).Copy

    Sheets("Totals").Select
    Range("B2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Attached Files Attached Files
    Last edited by Panda2000; 09-24-2012 at 06:49 PM.

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