We help IT Professionals succeed at work.
Get Started

Excel Macro: Action when field doesn't equal specific text

864 Views
Last Modified: 2013-11-25
I have the following code which works for filtering all the cells where it doesn't equal zero.

With Sheets("Menu").Rows("10:10")
    .AutoFilter Field:=8, Criteria1:="<>0"
    .AutoFilter Field:=9, Criteria1:="<>0"
    .AutoFilter Field:=10, Criteria1:="=0.00"
End With

How can I change the following code to filter when the text inside the cell doesn't equal "Apple"?  If I add quotation marks around Apple, I get an error.  Any help would be appreciated.

With Sheets("Menu").Rows("10:10")
    .AutoFilter Field:=12, Criteria:="<>Apple"
End With
With Sheets("Menu").Rows("10:10")
    .AutoFilter Field:=8, Criteria1:="<>0"
    .AutoFilter Field:=9, Criteria1:="<>0"
    .AutoFilter Field:=10, Criteria1:="=0.00"
End With
 
With Sheets("Menu").Rows("10:10")
    .AutoFilter Field:=12, Criteria:="<>Apple"
End With

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE