+ Reply to Thread
Results 1 to 3 of 3

Filtering macro gives error

  1. #1
    Registered User
    Join Date
    01-18-2010
    Location
    California, US
    MS-Off Ver
    Excel 2003
    Posts
    49

    Filtering macro gives error

    Hey everyone,
    I unfortunately inherited this workbook so I'm trying to add/update with new parameters.

    Everything else works fine but this part get caught up at the third and fourth (depending on which cell is populated) If Not statement, give me a run-time error 1004:

    If Not (IsEmpty([N25])) Then 'PVC
    ThisWorkbook.Sheets("Equipment").Range("K2:P2").AutoFilter Field:=5, Criteria1:="CPVC", Operator:=xlOr, Criteria2:="All Options"
    ThisWorkbook.Sheets("Fittings").Range("J2:N2").AutoFilter Field:=3, Criteria1:="P-", Operator:=xlOr, Criteria2:="All Options"
    End If

    If Not (IsEmpty([N26])) Then 'CPVC
    ThisWorkbook.Sheets("Equipment").Range("K2:P2").AutoFilter Field:=5, Criteria1:="CPVC", Operator:=xlOr, Criteria2:="All Options"
    ThisWorkbook.Sheets("Fittings").Range("J2:N2").AutoFilter Field:=3, Criteria1:="C-", Operator:=xlOr, Criteria2:="All Options"
    End If

    If Not (IsEmpty([N27])) Then 'PP
    ThisWorkbook.Sheets("Equipment").Range("K2:P2").AutoFilter Filed:=5, Criteria1:="PP", Operator:=xlOr, Criteria2:="All Options"
    ThisWorkbook.Sheets("Fittings").Range("J2:N2").AutoFilter Field:=3, Criteria1:="PP-", Operator:=xlOr, Criteria2:="All Options"
    End If

    If Not (IsEmpty([N28])) Then 'PVDF
    ThisWorkbook.Sheets("Equipment").Range("K2:P2").AutoFulter Filed:=5, Criteria1:="PV", Operator:=xlOr, Criteria2:="All Options"
    ThisWorkbook.Sheets("Fittings").Range("J2:N2").AutoFilter Field:=3, Criteria1:="PV-", Operator:=xlOr, Criteria2:="All Options"
    End If
    I don't understand why the first two If Not statements work correctly but the third and fourth do not.

    Any help would be greatly appreciated.

  2. #2
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Filtering macro gives error

    in your 3rd, there is "Filed" in stead of Field
    in your 4th there is "AutoFulter" in stead of "AutoFilter"

  3. #3
    Registered User
    Join Date
    01-18-2010
    Location
    California, US
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Filtering macro gives error

    Wow, I feel really dumb, fixing those typos did the trick. It's hard to catch when you've been staring at the same code for a while.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help with a runtime error on a filtering macro.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-11-2016, 09:29 AM
  2. [SOLVED] Error for filtering
    By ldurham in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2016, 08:58 AM
  3. Error when filtering out multiple cells
    By colangeloc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2015, 07:17 PM
  4. filtering with vba, always error?? need help....
    By Jhon Mustofa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-03-2013, 01:18 AM
  5. dynamic filtering vba error...need help..??
    By Jhon Mustofa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-02-2013, 05:04 AM
  6. Macro Error when Filtering in a Pivot Table
    By ssteines in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2013, 03:15 PM
  7. Replies: 14
    Last Post: 09-14-2009, 05:11 PM

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