VBA AutoFilter off Text and Cell Value Based

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
733
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2010
  5. 2007
Platform
  1. Windows
Hi, I have two scenarios where I am trying to solution and cant seem to get the results I was expecting

Trying to filter data based on a field not equaling 2 but the data is in text on my excel data and also filtering out a date based off a cell value

D5 =TEXT(TODAY(),"YYYYMMDD")
Today is 07/11/20 for reference

Range("10:10").AutoFilter Field:=5, Criteria1:="<>AB"
Range("10:10").AutoFilter Field:=3, Criteria1:="<>2"
Range("10:10").AutoFilter Field:=4, Criteria1:="<>Range(D5)"


DateDate#DateView Indicator
20200710​
20200710​
0
0​
AB
20200712​
20200712​
1
20200712​
AA
20200712​
20200712​
2
20200712​
AC
20200712​
20200712​
0
0​
AD
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try
VBA Code:
 Range("10:10").AutoFilter Field:=4, Criteria1:="<>"&Range("D5")
 
Upvote 0
Try
VBA Code:
 Range("10:10").AutoFilter Field:=4, Criteria1:="<>"&Range("D5")

Fluff - As usual you are the best. The one piece that still isn't working is my filter off of "2"' I think the problem resides with the data itself kicking out in text format?
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Ok so of course i have a variable. in that column I may have #2 and text 2. if i try this it gives me all Numbers.

Range("10:10").AutoFilter Field:=5, Criteria1:="<>2", Operator:=xlOr, Criteria2:="<>*2*"
 
Upvote 0
The best option is to clean up your data so that you either have numbers or text, rather than a mixture.
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,337
Members
448,568
Latest member
Honeymonster123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top