+ Reply to Thread
Results 1 to 2 of 2

Custom Autofilter Based on Cell Reference Value

  1. #1
    Registered User
    Join Date
    08-07-2010
    Location
    California,USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Smile Custom Autofilter Based on Cell Reference Value

    Hi all,

    I am trying to create a macro that filters out rows of data if Column 4 (PE Ratio) is more than cell reference "D2" (average industry PE Ratio). I also want to eliminate any rows where Column 4 (PE Ratio) reads "NA" - filtering out the "NA" rows is the easy part, but I am having trouble filtering out the rows that have PE Ratios (column 4) greater than the cell reference PE ratio ("D2").

    Sorry if that's a mouthful. Here is the section of code I have now:

    Range("A3:J3").Select 'Using Range instead of autofilter because the size of data varies when I import it.
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.AutoFilter
    Selection.AutoFilter Field:=4, Criteria1:="<" & Range("D2").Value 'THE PROBLEM
    Selection.AutoFilter Field:=4, Criteria1:="<>*NA*", Operator:=xlAnd 'THIS LINE WORKS

    Can anybody tell me how to tweak this code so that I can filter out rows based on my cell reference ("D2") value? D2 is a value, not a range, and it changes every time I click a button and import new data.

    Thanks,

    S Tassan

  2. #2
    Registered User
    Join Date
    08-01-2010
    Location
    American in Rovereto, Italy
    MS-Off Ver
    Excel 2010 home & Excel 2010 work
    Posts
    46

    Re: Custom Autofilter Based on Cell Reference Value

    Maybe you could try this. It's working on the fake PE data sheet that I threw together.
    I'm using your procedure, with the suggested modification, to add the autofilter.

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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