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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,215,330
Messages
6,124,310
Members
449,152
Latest member
PressEscape

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