VBA Code To Search a sheet, showing all results in a list within the sheet

SecFire

New Member
Joined
Nov 19, 2020
Messages
7
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hi. I have a spreadsheet in which i would like to use a search button to run a macro that will allow me to search, then narrow the results on the page down by only displaying matching results (as opposed to [ctrl]+F and having to continue to hit the next button. Could anyone point me in the right direction?
 

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.
VBA Code:
Private Sub CommandButton1_Click()
    TextBox1.Value = ""
    ActiveSheet.ListObjects("print_tbl").Range.AutoFilter
End Sub

Private Sub TextBox1_Change()
    ActiveSheet.ListObjects("print_tbl").Range.AutoFilter Field:=1, _
    Criteria1:="*" & TextBox1.Text & "*", Operator:=xlFilterValues
End Sub

Paste a TextBox on the sheet. You will enter your search term in the textbox. The more you enter in the textbox, the more refined the search becomes.

Paste a CommandButton on the sheet as well. Clicking the button clears the search.
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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