Filtering one column based on multiple arguements

M

Matt

I want to filter my spread sheet with a macro based on the information
in one column, the catch is that I'd like to hide anything that is one
of 5 different entries. From my initial testing I concluded that Excel
might not support more than 2 arguements per column in a filter. This
is a problem as I have thousands of entries with about 15 different
codes, but 5 of the codes are different ways of saying that something
didn't happen (each for a different reason which is important,
otherwise I could just use find/replace to code them all the same) I
want to view only the rows containing entries that did happen using a
filter, but the only way I have to do this is to write a macro that
checks each entry in the column to determine if it was one of these
codes and then hides them, stepping through a loop as it goes.

Here is what I've written for that piece:

Sub Operational()
Dim ColOTP As Integer
ColOTP = 7
For i = 2 To Worksheets("Data").UsedRange.Rows.Count
With Worksheets("Data").Cells(i, ColOTP)
If .Value = "Cancelled" Or _
.Value = "Weather" Or _
.Value = "Mechanical" Or _
.Value = "None" Or _
.Value = "Not Initialized" Then
Worksheets("Data").Rows(i).EntireRow.Hidden = True
End If
End With
Next i
End Sub

While this is functional as itself, it is not functional if I apply
this and then try to filter based on a quality of something in a
different column, doing so unhides all the entries that were hidden via
the above macro that meet the quality of the filter.
 
F

Franz Verga

Matt said:
I want to filter my spread sheet with a macro based on the information
in one column, the catch is that I'd like to hide anything that is one
of 5 different entries. From my initial testing I concluded that
Excel might not support more than 2 arguements per column in a
filter. This is a problem as I have thousands of entries with about
15 different codes, but 5 of the codes are different ways of saying
that something didn't happen (each for a different reason which is
important, otherwise I could just use find/replace to code them all
the same) I want to view only the rows containing entries that did
happen using a filter, but the only way I have to do this is to write
a macro that checks each entry in the column to determine if it was
one of these codes and then hides them, stepping through a loop as it
goes.

Hi Matt,

I think you could try to use Advanced Filter instead of Automatic Filter.
With Advanced Filter you can specify as many you want criteria to filter
your table...


--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top