Not sure if this type of search and display is possible...

pharrcide

New Member
Joined
Jun 12, 2014
Messages
5
For example, I have the following data set:

NameFruit1Fruit2Fruit3
1BobApplesOrangesPears
2JillOrangesApplesBananas
3BiffApplesOrangesPears
4TadBananasPearsPeaches
5PegGrapefruitApplesPears
6BillBananasPearsOranges
7DonOrangesOrangesOranges

<tbody>
</tbody>

I would like to be able to "filter" based on the word "Bananas" and then every row/record in the sheet containing Bananas (irrespective of which column) will be displayed and the rest hidden. In this example, entire rows 2, 4, and 6 would be displayed, the rest hidden. The basic and advanced filters don't seem to work and I haven't found the right macro example that will accomplish this either.

Any help is appreciated!!!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Maybe this VBA solution

Code:
Sub MM1()
Dim lr As Long, r As Long
Rows.EntireRow.Hidden = False
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = 2 To lr
    If Application.WorksheetFunction.CountIf(Range("B" & r & ":D" & r), "Bananas") = 0 Then
        Rows(r).EntireRow.Hidden = True
    End If
Next r
End Sub
 
Upvote 0
Hello Michael,

Your example was exactly what I need to get started. Made a few tweaks and it is doing exactly what I needed.

Many thanks!
 
Upvote 0
This can be done with Advanced Filter
If "Name" is in A1
Leave G1 blank and put the formula =(COUNTIF(B2:D2, "bananas")>0) in G2

Data Range - A1:D8
Criteria Range - B1:G2

will show the rows where "bananas" is in one of columns B:D
 
Upvote 0
Glad to help....Mikes method is more suited if you don't want to use VBA
AND
is simpler as it is a native function of Excel....(y)
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

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