ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filter multiple columns for one value (https://www.excelbanter.com/excel-programming/422317-filter-multiple-columns-one-value.html)

Miree

filter multiple columns for one value
 
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

Gary''s Student

filter multiple columns for one value
 
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
--
Gary''s Student - gsnu200825


"Miree" wrote:

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



All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com