Search a column for a value, hide rows that do not contain that value

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
153
Office Version
  1. 2016
Platform
  1. Windows
Hi

So I am looking to have a code that will search thru column P (range P2:P2000); search for the name of a person ex. Jane Doe (value in cell C6). If found, the corresponding row would be visible but rows that do have than name within that column, the row would be hidden

So I only want to be able to see the rows that contain the name entered in cell C6

any help would be appreciated

thank you
Dan
 
How about:
VBA Code:
Sub HideRows()
    Range("P7:P2000").AutoFilter Field:=1, Criteria1:=Range("C6").Value
End Sub
okay ... that worked but I have a "RESET" button that resets the page to its original view - all rows are visible....that no longer works
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Have your 'RESET' button point to the following:

VBA Code:
Sub ResetSheetFilter()
  If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
End Sub
 
Upvote 0
okay ... that worked
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,028
Members
449,092
Latest member
ikke

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