filter multiple columns for one value

M

Miree

I am trying to use excel to run a database(cos i really dont like office) but
i am relatively new to coding.

At the moment I am running a search by filtering the colums to match user
inputted data, I have come accross a problem as I need to search for one
value that can occur in up to 19 columns, but i have to keep every row of
data that it appears in just once.

Any help would be grreatly appreciated
Thank you
 
G

Gary''s Student

In this example, the data is in cols B thru T and in rows 2 thru 100. Put
the match value in A1 and run:

Sub OnlyOneTime()
v = Range("A1").Value
For i = 2 To 100
Set r = Range("B" & i & ":T" & i)
If Application.WorksheetFunction.CountIf(r, v) > 0 Then
Rows(i).Hidden = False
Else
Rows(i).Hidden = True
End If
Next
End Sub
 

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