VBA AutoFilter help

MartinL

Well-known Member
Joined
Oct 16, 2008
Messages
1,141
Office Version
  1. 365
Platform
  1. Windows
I have the following line of code that works
Rich (BB code):
rng.AutoFilter Field:=.Range("F1").Column, Criteria1:=vArray, Operator:=xlFilterValues

and the inverse that does not work
Rich (BB code):
rng.AutoFilter Field:=.Range("F1").Column, Criteria1:="<>" & vArray, Operator:=xlFilterValues
this was the only version that was accepted by the compiler
how should this line be written?

Martin
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
What is vArray? Presuming its as named, you would need to specify the element.
 
Upvote 0
Hi yes

Code:
vArray = Application.Transpose(.Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row).Formula)
its a list of codes that I want to keep
Code:
With Sheets("Data")
  .AutoFilterMode = False
  Set rng = .Range("A1:M" & .Cells(.Rows.Count, "A").End(xlUp).Row)
  rng.AutoFilter Field:=.Range("F1").Column, Criteria1:="<>" & vArray, Operator:=xlFilterValues
  rng.Offset(1).EntireRow.Delete
  .AutoFilterMode = False
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,383
Messages
6,136,246
Members
450,001
Latest member
KWeekley08

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