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:

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Name[/TD]
[TD]Fruit1[/TD]
[TD]Fruit2[/TD]
[TD]Fruit3[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Bob[/TD]
[TD]Apples[/TD]
[TD]Oranges[/TD]
[TD]Pears[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Jill[/TD]
[TD]Oranges[/TD]
[TD]Apples[/TD]
[TD]Bananas[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Biff[/TD]
[TD]Apples[/TD]
[TD]Oranges[/TD]
[TD]Pears[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Tad[/TD]
[TD]Bananas[/TD]
[TD]Pears[/TD]
[TD]Peaches[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Peg[/TD]
[TD]Grapefruit[/TD]
[TD]Apples[/TD]
[TD]Pears[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Bill[/TD]
[TD]Bananas[/TD]
[TD]Pears[/TD]
[TD]Oranges[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Don[/TD]
[TD]Oranges[/TD]
[TD]Oranges[/TD]
[TD]Oranges[/TD]
[/TR]
</tbody>[/TABLE]

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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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....:beerchug:
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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