filtering for <> not a numer

jordanburch

Active Member
Joined
Jun 10, 2016
Messages
440
Office Version
  1. 2016
Hey Guys,

I have the following

ActiveSheet.Range("$A$1:$AV$6000").AutoFilter Field:=6, Criteria1:=Array( _
"<>1110", "<>2220"), Operator:=xlFilterValues
basically I am trying to unclick the 1110 and 2220 values. its not working. can anyone help?

Jordan
 
Changing the format to a number will not affect the actual value in the cell, just the way it's displayed.
As those values are text & not numbers, either convert them to actual numbers, or put a formula in an unused column like
Excel Formula:
=OR(F2=1110&"",F2=2220&"")
and filter that column for False.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Changing the format to a number will not affect the actual value in the cell, just the way it's displayed.
As those values are text & not numbers, either convert them to actual numbers, or put a formula in an unused column like
Excel Formula:
=OR(F2=1110&"",F2=2220&"")
and filter that column for False.
got it thank for the help! So theres no way to filter out them as text even?
 
Upvote 0
Not that I'm aware of, but then I always ensure my numbers are numbers & not text.
 
Upvote 0
See if this does what you want.

VBA Code:
Sub AF()
  Dim d As Object
  Dim a As Variant
  Dim i As Long
  
  Set d = CreateObject("Scripting.Dictionary")
  With Range("A1:AV" & Range("F" & Rows.Count).End(xlUp).Row + 1)
    a = .Columns(6).Value
    For i = 2 To UBound(a)
      Select Case a(i, 1)
        Case "1110", "2220"
        Case Else: d(a(i, 1) & "") = 1
      End Select
    Next i
    .AutoFilter Field:=6, Criteria1:=d.keys(), Operator:=xlFilterValues
  End With
End Sub
 
Upvote 0
Not that I'm aware of, but then I always ensure my numbers are numbers & not text.
what about coding column f as real numbers. Should i just record that? or do you have a clever way thats more reliable of doing that?


See if this does what you want.

VBA Code:
Sub AF()
  Dim d As Object
  Dim a As Variant
  Dim i As Long
 
  Set d = CreateObject("Scripting.Dictionary")
  With Range("A1:AV" & Range("F" & Rows.Count).End(xlUp).Row + 1)
    a = .Columns(6).Value
    For i = 2 To UBound(a)
      Select Case a(i, 1)
        Case "1110", "2220"
        Case Else: d(a(i, 1) & "") = 1
      End Select
    Next i
    .AutoFilter Field:=6, Criteria1:=d.keys(), Operator:=xlFilterValues
  End With
End Sub
Works like a charm thank you Sir I really appreciate it!
 
Upvote 0
what about coding column f as real numbers.
You can use Text to columns, select col F & text to columns (on data tab) Delimited, next, uncheck all tick boxes & finish.
 
Upvote 0
You can use Text to columns, select col F & text to columns (on data tab) Delimited, next, uncheck all tick boxes & finish.
thanks fluff! I think that was from yesterday and I by accident quoted you. Thanks again for you help as well! Your method works great. Learning so much from you guys!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
thanks fluff! I think that was from yesterday and I by accident quoted you.
Does that mean that your question at the top of post #15 was directed at me? If so, can you expand on what you have and what you want to do?

Glad the AutoFilter code worked for you. :)
 
Upvote 0
Does that mean that your question at the top of post #15 was directed at me? If so, can you expand on what you have and what you want to do?

Glad the AutoFilter code worked for you. :)
no Peter sorry. Im not even sure how I did that lol. Your code worked great thanks again!
 
Upvote 0

Forum statistics

Threads
1,216,074
Messages
6,128,649
Members
449,462
Latest member
Chislobog

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