rjwebgraphix
Well-known Member
- Joined
- May 25, 2010
- Messages
- 590
Current version is XL2010. This is a modified recorded macro. The following code works for the current data on the current sheet, but that changes daily and can even change between sheets. When I recorded the macro I deselected the lines using the filter that I didn't want to see, but the code shows the lines I do want to see.
In this case we're talking about the line of criteria for Pig, Cat, Dog... etc. But I deselected Bear and Frog. Is there a simple way to reverse the criteria to be the ones I don't want to see instead of the ones I do want to see in the code or will I have to build the array myself outside of the Autofilter and pass in the array for the ones I do want to see?
The lines I don't want to see are fairly static. They will always be Bear and Frog, but Bear or Frog might not be present in the data at all.
Thanks, RJ
In this case we're talking about the line of criteria for Pig, Cat, Dog... etc. But I deselected Bear and Frog. Is there a simple way to reverse the criteria to be the ones I don't want to see instead of the ones I do want to see in the code or will I have to build the array myself outside of the Autofilter and pass in the array for the ones I do want to see?
The lines I don't want to see are fairly static. They will always be Bear and Frog, but Bear or Frog might not be present in the data at all.
Thanks, RJ
Code:
Sub forumwork()
Dim OARsht As Worksheet
Set OARsht = Sheets("TGS OARV")
Dim lr As Long
Dim c1 As Range
Dim c2 As Range
Dim rng As Range
lr = OARsht.Range("A65536").End(xlUp).Row
Set c1 = Cells(1, "A")
Set c2 = Cells(lr, "F")
Set rng = Range(c1, c2)
rng.AutoFilter
rng.AutoFilter Field:=3, Criteria1:=Array( _
"Pig", "Cat", "Dog", _
"Elephant", "Mouse", "Lion", _
"Monkey"), Operator:=xlFilterValues
End Sub